Está en la página 1de 8

UNIVERSIDAD AUTONOMA TOMAS FRIAS MAT-205

BISECCION O PUNTO MEDIO

Function fun(ByVal x As Double) As Double

fun = x ^ 4 - 15.2 * x ^ 3 + 59.7 * x ^ 2 - 81.6 * x + 36

End Function

Sub BiseccionPuntoMedio()

Dim a, b, raiz, tol, xm, error As Double

a = Val(InputBox("Ingrese el extremo izquierdo del intervalo:"))

b = Val(InputBox("Ingrese el extremo derecho del intervalo:"))

Cells(4, 3) = " ( " & a & " , " & b & " ) "

tol = Val(InputBox("Ingrese el error de la tolerancia:"))

Cells(6, 3) = tol

raiz = Val(InputBox("Ingrese el valor verdadero de la raiz:"))

Cells(8, 3) = Str(raiz)

Do

xm = (a + b) / 2

If fun(a) * fun(xm) < 0 Then

b = xm

Else

a = xm

End If

error = Abs(((raiz - xm) / raiz) * 100)

Loop While error > tol

MsgBox (xm)

End Sub

ING. MEDINA CORICO IVER FUNCIONES NO LINEALES


UNIVERSIDAD AUTONOMA TOMAS FRIAS MAT-205
2

BISECCION O PUNTO MEDIO SIN VALOR VERDADERO

Function fun(ByVal x As Double) As Double

fun = x ^ 4 - 15.2 * x ^ 3 + 59.7 * x ^ 2 - 81.6 * x + 36

End Function

Sub BiseccionPuntoMedio()

Dim a, b, raiz, tol, xm, error As Double

a = Val(InputBox("Ingrese el extremo izquierdo del intervalo:"))

b = Val(InputBox("Ingrese el extremo derecho del intervalo:"))

Cells(4, 3) = " ( " & a & " , " & b & " ) "

tol = Val(InputBox("Ingrese el error de la tolerancia:"))

Cells(6, 3) = tol

va = a

Do

xm = (a + b) / 2

If fun(a) * fun(xm) < 0 Then

b = xm

Else

a = xm

End If

error = Abs(((xm - va) / xm) * 100)

va = xm

Loop While error > tol

MsgBox (xm)

End Sub

ING. MEDINA CORICO IVER FUNCIONES NO LINEALES


UNIVERSIDAD AUTONOMA TOMAS FRIAS MAT-205
3

METODO DE LA REGLA FALSA

Function fun(ByVal x As Double) As Double

fun = x ^ 4 - 15.2 * x ^ 3 + 59.7 * x ^ 2 - 81.6 * x + 36

End Function

Sub BiseccionPuntoMedio()

Dim a, b, raiz, tol, xm, error As Double

a = Val(InputBox("Ingrese el extremo izquierdo del intervalo:"))

b = Val(InputBox("Ingrese el extremo derecho del intervalo:"))

Cells(4, 3) = " ( " & a & " , " & b & " ) "

tol = Val(InputBox("Ingrese el error de la tolerancia:"))

Cells(6, 3) = tol

raiz = Val(InputBox("Ingrese el valor verdadero de la raiz:"))

Cells(8, 3) = Str(raiz)

Do

xm = (a * fun(b) - b * fun(a)) / (fun(b) - fun(a))

If fun(a) * fun(xm) < 0 Then

b = xm

Else

a = xm

End If

error = Abs(((raiz - xm) / raiz) * 100)

Loop While error > tol

MsgBox (xm)

End Sub

ING. MEDINA CORICO IVER FUNCIONES NO LINEALES


UNIVERSIDAD AUTONOMA TOMAS FRIAS MAT-205
4

METODO DE LA REGLA FALSA SIN VALOR VERDADERO

Function fun(ByVal x As Double) As Double

fun = x ^ 4 - 15.2 * x ^ 3 + 59.7 * x ^ 2 - 81.6 * x + 36

End Function

Sub BiseccionPuntoMedio()

Dim a, b, raiz, tol, xm, error As Double

a = Val(InputBox("Ingrese el extremo izquierdo del intervalo:"))

b = Val(InputBox("Ingrese el extremo derecho del intervalo:"))

Cells(4, 3) = " ( " & a & " , " & b & " ) "

tol = Val(InputBox("Ingrese el error de la tolerancia:"))

Cells(6, 3) = tol

va = a

Do

xm = (a * fun(b) - b * fun(a)) / (fun(b) - fun(a))

If fun(a) * fun(xm) < 0 Then

b = xm

Else

a = xm

End If

error = Abs(((xm - va) / xm) * 100)

va = xm

Loop While error > tol

MsgBox (xm)

End Sub

ING. MEDINA CORICO IVER FUNCIONES NO LINEALES


UNIVERSIDAD AUTONOMA TOMAS FRIAS MAT-205
5

METODO DE NEWTON RAPSON 1er ORDEN

Function fun(ByVal x As Double) As Double

fun = x ^ 4 - 15.2 * x ^ 3 + 59.7 * x ^ 2 - 81.6 * x + 36

End Function

Function fund(ByVal x As Double) As Double

fund = 4 * x ^ 3 - 45.6 * x ^ 2 + 119.4 * x - 81.6

End Function

Sub BiseccionPuntoMedio()

Dim x0, raiz, tol, xi, error As Double

xi = Val(InputBox("Ingrese un valor inicial:"))

Cells(4, 3) = xi

tol = Val(InputBox("Ingrese el error de la tolerancia:"))

Cells(6, 3) = tol

Do

x0 = xi

xi = x0 - (fun(x0) / fund(x0))

error = Abs(xi - x0)

Loop While error > tol

MsgBox (xi)

End Sub

ING. MEDINA CORICO IVER FUNCIONES NO LINEALES


UNIVERSIDAD AUTONOMA TOMAS FRIAS MAT-205
6

METODO DE NEWTON RAPSON 2do ORDEN

Function fun(ByVal x As Double) As Double

fun = x ^ 4 - 15.2 * x ^ 3 + 59.7 * x ^ 2 - 81.6 * x + 36

End Function

Function fund(ByVal x As Double) As Double

fund = 4 * x ^ 3 - 45.6 * x ^ 2 + 119.4 * x - 81.6

End Function

Function fundd(ByVal x As Double) As Double

fundd = 12 * x ^ 2 - 91.2 * x + 119.4

End Function

Sub BiseccionPuntoMedio()

Dim x0, raiz, tol, xi, error As Double

xi = Val(InputBox("Ingrese un valor inicial:"))

Cells(4, 3) = xi

tol = Val(InputBox("Ingrese el error de la tolerancia:"))

Cells(6, 3) = tol

Do

x0 = xi

xi = x0 + (1 / ((fundd(x0) / (2 * fund(x0))) - (fund(x0) / fun(x0))))

error = Abs(xi - x0)

Loop While error > tol

MsgBox (xi)

End Sub

ING. MEDINA CORICO IVER FUNCIONES NO LINEALES


UNIVERSIDAD AUTONOMA TOMAS FRIAS MAT-205
7

METODO DE LA SECANTE

Function fun(ByVal x As Double) As Double

fun = x ^ 4 - 15.2 * x ^ 3 + 59.7 * x ^ 2 - 81.6 * x + 36

End Function

Sub BiseccionPuntoMedio()

Dim x0, x1, raiz, tol, xi, error As Double

xi = Val(InputBox("Ingrese el primer valor inicial:"))

x1 = Val(InputBox("Ingrese el segundo valor inicial:"))

Cells(4, 3) = xi

tol = Val(InputBox("Ingrese el error de la tolerancia:"))

Cells(6, 3) = tol

Do

x0 = x1

x1 = xi

xi = x1 - ((x1 - x0) * fun(x1)) / (fun(x1) - fun(x0))

error = Abs(xi - x0)

Loop While error > tol

MsgBox (xi)

End Sub

ING. MEDINA CORICO IVER FUNCIONES NO LINEALES


UNIVERSIDAD AUTONOMA TOMAS FRIAS MAT-205
8

ING. MEDINA CORICO IVER FUNCIONES NO LINEALES

También podría gustarte