Está en la página 1de 11

MENU DE RAICES

Module Module1

Sub Main()
Dim a, b, opcion As Single
b = busca(a, b)
a = b - 0.1
Do
menu(opcion)
Select Case (opcion)
Case 1
Console.Clear()
Console.ForegroundColor = ConsoleColor.Cyan
Console.SetCursorPosition(30, 3)
Console.WriteLine("El intervalo va de {0} a {1}", a, b)
Console.ReadLine()
Case 2
Console.Clear()
Console.ForegroundColor = ConsoleColor.Cyan
Console.SetCursorPosition(30, 3)
Console.WriteLine("El punto es: {0}", biseccion(a, b))
Console.ReadLine()
Case 3
Console.Clear()
Console.ForegroundColor = ConsoleColor.Cyan
Console.SetCursorPosition(30, 3)
Console.WriteLine("El punto es: {0}", newton(a, b))
Console.ReadLine()
Case 4
Console.Clear()
Console.ForegroundColor = ConsoleColor.Cyan
Console.SetCursorPosition(30, 3)
Console.WriteLine("El punto es: {0}", regula(a, b))
Console.ReadLine()
Case 5
Console.Clear()
Console.ForegroundColor = ConsoleColor.Cyan
Console.SetCursorPosition(30, 3)
Console.WriteLine("El punto es: {0}", converge(a, b))
Console.ReadLine()
Case 6
Console.Clear()
Console.ForegroundColor = ConsoleColor.Cyan
Console.SetCursorPosition(36, 10)
Console.WriteLine("ADIOS")
Console.ReadLine()
End Select
Loop While (opcion <= 6)

End Sub
Sub menu(ByRef op As Integer)
Console.ForegroundColor = ConsoleColor.Magenta
Console.SetCursorPosition(33, 3)
Console.WriteLine("MENU DE RAICES")
Console.SetCursorPosition(30, 5)
Console.WriteLine("1. METODO BUSCA")
Console.SetCursorPosition(30, 6)
Console.WriteLine("2. METODO BISECCION ")
Console.SetCursorPosition(30, 7)
Console.WriteLine("3. METODO NEWTON RAPHSON")
Console.SetCursorPosition(30, 8)
Console.WriteLine("4. METODO REGULA FALSI")
Console.SetCursorPosition(30, 9)
Console.WriteLine("5. METODO CONVERGE")
Console.SetCursorPosition(30, 10)
Console.WriteLine("6. FIN")
Console.SetCursorPosition(30, 11)
Console.Write("7. SELECCIONAR OPCION --> ")
op = Console.ReadLine

End Sub
Function derivada(ByVal x As Single)
Dim h, D As Single
h = 0.000001
D = (f(x + h) - f(x)) / h
Return (D)
End Function
Function f(ByVal y As Single) As Single
Return ((y * y) + (2 * y) - 4)
End Function
Function busca(ByRef x As Single, ByRef y As Single) As Single
Dim z As Single
z = 0
While (f(z) < 0)
z = z + 0.1
End While
Return (z)
End Function
Function biseccion(ByVal x As Single, ByVal y As Single) As Single
Dim c As Single
While (y - x > 0.00001)
c = (x + y) / 2
If (f(x) * f(c) > 0) Then
x = c
Else
y = c
End If
End While
Return (c)
End Function
Function newton(ByVal x As Single, y As Single) As Single
Dim D, XN As Single
D = 10
While (D > 0.00001)
XN = y - (f(y) / derivada(y))
D = y - XN
y = XN
End While
Return (XN)
End Function
Function regula(ByVal a As Single, ByVal b As Single)
Dim d, c As Single
d = 10
While d > 0.00001
c = ((f(a) * b - f(b) * a) / (f(a) - f(b)))
If ((F(a) * F(c)) > 0) Then
d = c - a
a = c
Else
d = b - c
b = c
End If
End While
Return c
End Function
Function converge(ByVal x As Single, y As Single) As Single
Dim D, XN As Single
D = 10
While (D > 0.00001)
XN = (4 - 2 * x) ^ (1 / 2)
D = (x - XN)
x = XN
End While
Return (XN)
End Function
End Module
VOLUMEN DEL CONO
Module Module1
Sub ingresar(ByRef a As Single, ByRef b As Single, ByRef ND As Single)
Console.Write("Ingrese el intervalo menor: ")
a = Console.ReadLine
Console.Write("Ingrese el intervalo mayor: ")
b = Console.ReadLine
Console.Write("Ingrese el numero de divisiones: ")
ND = Console.ReadLine
End Sub
Function F(ByVal x As Single)
Return (x / 2)
End Function
Function volumen(ByVal a As Single, ByVal b As Single, ByVal nd As Single)
Dim x As Single = a, dx As Single, rm As Single, v As Single, vt As Single
dx = (b - a) / nd
While (x < b)
rm = (F(x) + F(x + dx)) / 2
v = Math.PI * Math.Pow(rm, 2) * dx
vt = vt + v
x = x + dx
End While
Return vt
End Function
Sub Main()
Dim a, b, nd As Single
ingresar(a, b, nd)
Console.WriteLine("el volumen del cono es:{0}", volumen(a, b, nd))
Console.ReadLine()
End Sub
End Module
RECURSIVIDAD-INTEGRALES

INSCRITOS
Module Module1
Sub ingresar(ByRef a As Single, ByRef b As Single, ByRef ND As Single)
Console.Write("Ingrese el intervalo menor: ")
a = Console.ReadLine
Console.Write("Ingrese el intervalo mayor: ")
b = Console.ReadLine
Console.Write("Ingrese el numero de divisiones: ")
ND = Console.ReadLine
End Sub
Function F(ByVal x As Single)
Return (x * x)
End Function
Function Inscritos(ByVal a As Single, ByVal b As Single, ByVal dx As Single)

If (a + dx = b) Then
Return F(a + dx) * dx
Else
Return (F(b) * dx) + Inscritos(a, b - dx, dx)
End If
End Function
Sub Main()
Dim a, b, nd, dx As Single
ingresar(a, b, nd)
dx = (b - a) / nd
Console.WriteLine("La integral es:{0}", Inscritos(a, b, dx))
Console.ReadLine()
End Sub
End Module
CIRCUNSCRITOS
Module Module1
Sub ingresar(ByRef a As Single, ByRef b As Single, ByRef ND As Single)
Console.Write("Ingrese el intervalo menor: ")
a = Console.ReadLine
Console.Write("Ingrese el intervalo mayor: ")
b = Console.ReadLine
Console.Write("Ingrese el numero de divisiones: ")
ND = Console.ReadLine
End Sub
Function F(ByVal x As Single)
Return (x * x)
End Function
Function circunscritos(ByVal a As Single, ByVal b As Single, ByVal dx As Single)

If (a = b - dx) Then
Return F(b - dx) * dx
Else
Return (F(a) * dx) + circunscritos(a + dx, b, dx)
End If
End Function
Sub Main()
PUNTOS MEDIOS

Module Module1
Sub ingresar(ByRef a As Single, ByRef b As Single, ByRef ND As Single)
Console.Write("Ingrese el intervalo menor: ")
a = Console.ReadLine
Console.Write("Ingrese el intervalo mayor: ")
b = Console.ReadLine
Console.Write("Ingrese el numero de divisiones: ")
ND = Console.ReadLine
End Sub
Function F(ByVal x As Single)
Return (x * x)
End Function
Function puntosmedios(ByVal xm As Single, ByVal xa As Single, ByVal dx As
Single)
If (xm = xa) Then
Return F(xm) * dx
Else
Return (F(xa) * dx) + puntosmedios(xm, xa - dx, dx)
End If
End Function
Sub Main()
Dim a, b, nd, dx, xm, xa As Single
ingresar(a, b, nd)
dx = (b - a) / nd
xm = (a + (a + dx)) / 2
xa = b - Math.Pow(dx, 2)
Console.WriteLine("La integral es:{0}", puntosmedios(xm, xa, dx))
Console.ReadLine()
End Sub
End Module
TRAPECIAL
Module Module1
Sub ingresar(ByRef a As Single, ByRef b As Single, ByRef ND As Single)
Console.Write("Ingrese el intervalo menor: ")
a = Console.ReadLine
Console.Write("Ingrese el intervalo mayor: ")
b = Console.ReadLine
Console.Write("Ingrese el numero de divisiones: ")
ND = Console.ReadLine
End Sub
Function F(ByVal x As Single)
Return (x * x)
End Function
Function trapecial(ByVal a As Single, ByVal b As Single, ByVal dx As Single)
If (a = b - dx) Then
Return (F(b - dx) + F(b)) / 2 * dx
Else
Return (F(a) + F(a + dx)) / 2 * dx + trapecial(a + dx, b, dx)
End If
End Function
Sub Main()
Dim a, b, nd, dx As Single
ingresar(a, b, nd)
dx = (b - a) / nd
Console.WriteLine("La integral es:{0}", trapecial(a, b, dx))
Console.ReadLine()
End Sub
End Module

También podría gustarte