SlideShare a Scribd company logo
1 of 5
Download to read offline
Cálculo de la raíz de una ecuación no lineal mediante el Método Numérico de la Secante
Utilizando macros de VBA de Excel
Ing. Néstor Augusto Oyarce Linares
naoyarcel@gmail.com
aSecanteGrafica - 1
Option Explicit
Sub XY_11_Dic_2020_5()
Dim X As Double, Y As Double, i As Integer
'Método Numérico de LA SECANTE
'14 de Diciembre de 2020, ejercicio 5
Cells.Clear
Cells(1, 1).Value = " ECUACIÓN : "
Cells(3, 1).Value = " X^3+2*X^2+10*X-20"
Cells(1, 2).Value = " ENSAYOS : "
Cells(3, 2).Value = " X "
Cells(3, 3).Value = " Y "
For i = 1 To 10
X = 1 + i / 10
Y = (X) ^ (3) + 2 * (X) ^ (2) + 10 * X - 20
Cells(i + 3, 2).Value = X
Cells(i + 3, 3).Value = Y
If Y > 0 Then Exit For
Next i
Range("A1", "A3").Font.Bold = True
Cells.EntireColumn.AutoFit
End Sub
Sub Crea_grafico()
Dim grafico As ChartObject
Dim wks As Worksheet
Set wks = ActiveWorkbook.Sheets("Hoja1")
Set grafico = wks.ChartObjects.Add(Left:=400, Width:=450, Top:=50, Height:=200)
grafico.Name = "Grafico_1"
grafico.Chart.ChartType = xlXYScatterSmoothNoMarkers
grafico.Chart.SetSourceData Source:=wks.Range("B4:D15")
End Sub
' Ing. Néstor Augusto Oyarce Linares
ECUACIÓN : ENSAYOS :
X^3+2*X^2+10*X-20 X Y
1.1 -5.249
1.2 -3.392
1.3 -1.423
1.4 0.664
-6
-5
-4
-3
-2
-1
0
1
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6
Series1
Series2
bSecanteCalculo - 1
Option Explicit
Sub Parte2_SECANTE()
Dim Xa As Double, X As Double, Ya As Double, i As Integer, Xb As Double, Xm As Double, Yb As Double
Dim Err As Double, Ym As Double, j As Integer, Y As Double, gx As Double
Cells.Clear
Cells(1, 1).Value = "Método Numérico de la Secante"
Cells(2, 2).Value = "Valor de X"
Cells(2, 3).Value = "Valor de Y"
Cells(2, 5).Value = " Xf "
Cells(2, 6).Value = " Yf "
Cells(2, 7).Value = "Iteraciones"
Xa = 1.3
Xb = 1.4
For j = 1 To 20
Ya = (Xa) ^ (3) + 2 * (Xa) ^ (2) + 10 * Xa - 20
Yb = (Xb) ^ (3) + 2 * (Xb) ^ (2) + 10 * Xb - 20
Xm = Xb - Yb * (Xa - Xb) / (Ya - Yb)
Ym = (Xm) ^ (3) + 2 * (Xm) ^ (2) + 10 * Xm - 20
Err = Abs(Xm - Xb)
Cells(j + 3, 2).Value = Xm
Cells(j + 3, 3).Value = Ym
If Err <= 0.000001 Then Exit For
Xa = Xb
Xb = Xm
Next j
X = Xm
Y = (X) ^ (3) + 2 * (X) ^ (2) + 10 * X - 20
Cells(4, 5).Value = X
Cells(4, 6).Value = Y
Cells(4, 7).Value = j
Range("E1", "E4").Font.Bold = True
Range("E1", "E4").Font.Color = RGB(8, 44, 196)
Cells.EntireColumn.AutoFit
End Sub
' Ing. Néstor Augusto Oyarce Linares
Método Numérico de la Secante
Valor de X Valor de Y Xf Yf Iteraciones
1.368183996 -0.013163968 1.368808108 -3.5083E-14 4
1.368802495 -0.000118417
1.368808109 2.13941E-08
1.368808108 -3.5083E-14

More Related Content

Similar to 0.0. secante naol

Seminar PSU 09.04.2013 - 10.04.2013 MiFIT, Arbuzov Vyacheslav
Seminar PSU 09.04.2013 - 10.04.2013 MiFIT, Arbuzov VyacheslavSeminar PSU 09.04.2013 - 10.04.2013 MiFIT, Arbuzov Vyacheslav
Seminar PSU 09.04.2013 - 10.04.2013 MiFIT, Arbuzov Vyacheslav
Vyacheslav Arbuzov
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
krishna_093
 

Similar to 0.0. secante naol (20)

0.0. biseccion
0.0. biseccion0.0. biseccion
0.0. biseccion
 
0.0. secante modificada
0.0. secante modificada0.0. secante modificada
0.0. secante modificada
 
0.0. punto fijo
0.0. punto fijo0.0. punto fijo
0.0. punto fijo
 
bobok
bobokbobok
bobok
 
4th Semeste Electronics and Communication Engineering (June-2016) Question Pa...
4th Semeste Electronics and Communication Engineering (June-2016) Question Pa...4th Semeste Electronics and Communication Engineering (June-2016) Question Pa...
4th Semeste Electronics and Communication Engineering (June-2016) Question Pa...
 
4th semester Computer Science and Information Science Engg (2013 December) Qu...
4th semester Computer Science and Information Science Engg (2013 December) Qu...4th semester Computer Science and Information Science Engg (2013 December) Qu...
4th semester Computer Science and Information Science Engg (2013 December) Qu...
 
ISI MSQE Entrance Question Paper (2008)
ISI MSQE Entrance Question Paper (2008)ISI MSQE Entrance Question Paper (2008)
ISI MSQE Entrance Question Paper (2008)
 
Math cbse samplepaper
Math cbse samplepaperMath cbse samplepaper
Math cbse samplepaper
 
4th Semester (July-2016) Civil Engineering Question Paper
4th Semester (July-2016) Civil Engineering Question Paper4th Semester (July-2016) Civil Engineering Question Paper
4th Semester (July-2016) Civil Engineering Question Paper
 
Seminar PSU 09.04.2013 - 10.04.2013 MiFIT, Arbuzov Vyacheslav
Seminar PSU 09.04.2013 - 10.04.2013 MiFIT, Arbuzov VyacheslavSeminar PSU 09.04.2013 - 10.04.2013 MiFIT, Arbuzov Vyacheslav
Seminar PSU 09.04.2013 - 10.04.2013 MiFIT, Arbuzov Vyacheslav
 
ISI MSQE Entrance Question Paper (2010)
ISI MSQE Entrance Question Paper (2010)ISI MSQE Entrance Question Paper (2010)
ISI MSQE Entrance Question Paper (2010)
 
Cbse Class 12 Maths Sample Paper 2012
Cbse Class 12 Maths Sample Paper 2012Cbse Class 12 Maths Sample Paper 2012
Cbse Class 12 Maths Sample Paper 2012
 
DurbinWatsonVBA
DurbinWatsonVBADurbinWatsonVBA
DurbinWatsonVBA
 
4th Semester (June; July-2015) Computer Science and Information Science Engin...
4th Semester (June; July-2015) Computer Science and Information Science Engin...4th Semester (June; July-2015) Computer Science and Information Science Engin...
4th Semester (June; July-2015) Computer Science and Information Science Engin...
 
138191 rvsp lecture notes
138191 rvsp lecture notes138191 rvsp lecture notes
138191 rvsp lecture notes
 
3rd Semester (June-2014) Computer Science and Information Science Engineering...
3rd Semester (June-2014) Computer Science and Information Science Engineering...3rd Semester (June-2014) Computer Science and Information Science Engineering...
3rd Semester (June-2014) Computer Science and Information Science Engineering...
 
Exercises in Linear Algebra - Matrices and determinants
Exercises in Linear Algebra - Matrices and determinantsExercises in Linear Algebra - Matrices and determinants
Exercises in Linear Algebra - Matrices and determinants
 
Arrays
ArraysArrays
Arrays
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
4th Semester CS / IS (2013-June) Question Papers
4th Semester CS / IS (2013-June) Question Papers 4th Semester CS / IS (2013-June) Question Papers
4th Semester CS / IS (2013-June) Question Papers
 

More from Agua SAC (6)

0.0. newton raphson
0.0. newton raphson0.0. newton raphson
0.0. newton raphson
 
Publi 05.03.2015
Publi 05.03.2015Publi 05.03.2015
Publi 05.03.2015
 
Trapecio tarea 1
Trapecio tarea 1Trapecio tarea 1
Trapecio tarea 1
 
Sistema información geografica y dengue
Sistema información geografica y dengueSistema información geografica y dengue
Sistema información geografica y dengue
 
Ejercicio amp2 naol
Ejercicio amp2 naolEjercicio amp2 naol
Ejercicio amp2 naol
 
Ejercicio amp2 naol
Ejercicio amp2 naolEjercicio amp2 naol
Ejercicio amp2 naol
 

Recently uploaded

Seizure stage detection of epileptic seizure using convolutional neural networks
Seizure stage detection of epileptic seizure using convolutional neural networksSeizure stage detection of epileptic seizure using convolutional neural networks
Seizure stage detection of epileptic seizure using convolutional neural networks
IJECEIAES
 
Microkernel in Operating System | Operating System
Microkernel in Operating System | Operating SystemMicrokernel in Operating System | Operating System
Microkernel in Operating System | Operating System
Sampad Kar
 
1893-part-1-2016 for Earthquake load design
1893-part-1-2016 for Earthquake load design1893-part-1-2016 for Earthquake load design
1893-part-1-2016 for Earthquake load design
AshishSingh1301
 
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
drjose256
 
Final DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manualFinal DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manual
BalamuruganV28
 
electrical installation and maintenance.
electrical installation and maintenance.electrical installation and maintenance.
electrical installation and maintenance.
benjamincojr
 
Online crime reporting system project.pdf
Online crime reporting system project.pdfOnline crime reporting system project.pdf
Online crime reporting system project.pdf
Kamal Acharya
 

Recently uploaded (20)

Seizure stage detection of epileptic seizure using convolutional neural networks
Seizure stage detection of epileptic seizure using convolutional neural networksSeizure stage detection of epileptic seizure using convolutional neural networks
Seizure stage detection of epileptic seizure using convolutional neural networks
 
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdf
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdfInvolute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdf
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdf
 
Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...
 
Research Methodolgy & Intellectual Property Rights Series 2
Research Methodolgy & Intellectual Property Rights Series 2Research Methodolgy & Intellectual Property Rights Series 2
Research Methodolgy & Intellectual Property Rights Series 2
 
Insurance management system project report.pdf
Insurance management system project report.pdfInsurance management system project report.pdf
Insurance management system project report.pdf
 
Electrical shop management system project report.pdf
Electrical shop management system project report.pdfElectrical shop management system project report.pdf
Electrical shop management system project report.pdf
 
Augmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptxAugmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptx
 
5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...
 
Microkernel in Operating System | Operating System
Microkernel in Operating System | Operating SystemMicrokernel in Operating System | Operating System
Microkernel in Operating System | Operating System
 
Vip ℂall Girls Karkardooma Phone No 9999965857 High Profile ℂall Girl Delhi N...
Vip ℂall Girls Karkardooma Phone No 9999965857 High Profile ℂall Girl Delhi N...Vip ℂall Girls Karkardooma Phone No 9999965857 High Profile ℂall Girl Delhi N...
Vip ℂall Girls Karkardooma Phone No 9999965857 High Profile ℂall Girl Delhi N...
 
Operating System chapter 9 (Virtual Memory)
Operating System chapter 9 (Virtual Memory)Operating System chapter 9 (Virtual Memory)
Operating System chapter 9 (Virtual Memory)
 
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdflitvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
 
1893-part-1-2016 for Earthquake load design
1893-part-1-2016 for Earthquake load design1893-part-1-2016 for Earthquake load design
1893-part-1-2016 for Earthquake load design
 
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
 
Final DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manualFinal DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manual
 
SLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptxSLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptx
 
Piping and instrumentation diagram p.pdf
Piping and instrumentation diagram p.pdfPiping and instrumentation diagram p.pdf
Piping and instrumentation diagram p.pdf
 
electrical installation and maintenance.
electrical installation and maintenance.electrical installation and maintenance.
electrical installation and maintenance.
 
handbook on reinforce concrete and detailing
handbook on reinforce concrete and detailinghandbook on reinforce concrete and detailing
handbook on reinforce concrete and detailing
 
Online crime reporting system project.pdf
Online crime reporting system project.pdfOnline crime reporting system project.pdf
Online crime reporting system project.pdf
 

0.0. secante naol

  • 1. Cálculo de la raíz de una ecuación no lineal mediante el Método Numérico de la Secante Utilizando macros de VBA de Excel Ing. Néstor Augusto Oyarce Linares naoyarcel@gmail.com
  • 2. aSecanteGrafica - 1 Option Explicit Sub XY_11_Dic_2020_5() Dim X As Double, Y As Double, i As Integer 'Método Numérico de LA SECANTE '14 de Diciembre de 2020, ejercicio 5 Cells.Clear Cells(1, 1).Value = " ECUACIÓN : " Cells(3, 1).Value = " X^3+2*X^2+10*X-20" Cells(1, 2).Value = " ENSAYOS : " Cells(3, 2).Value = " X " Cells(3, 3).Value = " Y " For i = 1 To 10 X = 1 + i / 10 Y = (X) ^ (3) + 2 * (X) ^ (2) + 10 * X - 20 Cells(i + 3, 2).Value = X Cells(i + 3, 3).Value = Y If Y > 0 Then Exit For Next i Range("A1", "A3").Font.Bold = True Cells.EntireColumn.AutoFit End Sub Sub Crea_grafico() Dim grafico As ChartObject Dim wks As Worksheet Set wks = ActiveWorkbook.Sheets("Hoja1") Set grafico = wks.ChartObjects.Add(Left:=400, Width:=450, Top:=50, Height:=200) grafico.Name = "Grafico_1" grafico.Chart.ChartType = xlXYScatterSmoothNoMarkers grafico.Chart.SetSourceData Source:=wks.Range("B4:D15") End Sub ' Ing. Néstor Augusto Oyarce Linares
  • 3. ECUACIÓN : ENSAYOS : X^3+2*X^2+10*X-20 X Y 1.1 -5.249 1.2 -3.392 1.3 -1.423 1.4 0.664 -6 -5 -4 -3 -2 -1 0 1 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 Series1 Series2
  • 4. bSecanteCalculo - 1 Option Explicit Sub Parte2_SECANTE() Dim Xa As Double, X As Double, Ya As Double, i As Integer, Xb As Double, Xm As Double, Yb As Double Dim Err As Double, Ym As Double, j As Integer, Y As Double, gx As Double Cells.Clear Cells(1, 1).Value = "Método Numérico de la Secante" Cells(2, 2).Value = "Valor de X" Cells(2, 3).Value = "Valor de Y" Cells(2, 5).Value = " Xf " Cells(2, 6).Value = " Yf " Cells(2, 7).Value = "Iteraciones" Xa = 1.3 Xb = 1.4 For j = 1 To 20 Ya = (Xa) ^ (3) + 2 * (Xa) ^ (2) + 10 * Xa - 20 Yb = (Xb) ^ (3) + 2 * (Xb) ^ (2) + 10 * Xb - 20 Xm = Xb - Yb * (Xa - Xb) / (Ya - Yb) Ym = (Xm) ^ (3) + 2 * (Xm) ^ (2) + 10 * Xm - 20 Err = Abs(Xm - Xb) Cells(j + 3, 2).Value = Xm Cells(j + 3, 3).Value = Ym If Err <= 0.000001 Then Exit For Xa = Xb Xb = Xm Next j X = Xm Y = (X) ^ (3) + 2 * (X) ^ (2) + 10 * X - 20 Cells(4, 5).Value = X Cells(4, 6).Value = Y Cells(4, 7).Value = j Range("E1", "E4").Font.Bold = True Range("E1", "E4").Font.Color = RGB(8, 44, 196) Cells.EntireColumn.AutoFit End Sub ' Ing. Néstor Augusto Oyarce Linares
  • 5. Método Numérico de la Secante Valor de X Valor de Y Xf Yf Iteraciones 1.368183996 -0.013163968 1.368808108 -3.5083E-14 4 1.368802495 -0.000118417 1.368808109 2.13941E-08 1.368808108 -3.5083E-14