UNIVERSIDAD NACIONAL DE
SAN AGUSTIN
FACULTAD DE PRODUCCION Y
SERVICIOS ESCUELA PROFESIONAL DE
INGENIERIA INDUSTRIAL
PROGRAMACION Y
METODOS NUMERICOS
PROFESOR: JUAN CARLOS
TORREBLANCA
EVALUACIÓN: SEGUNDA TAREA
GRUPO: ” GENIOMATICOS”
INTEGRANTES:
TINTAYA CHUCTAYA , ELIZABETH
CASTRO BLANCO ,NICOLE
AREQUIPA- PERU
2017
Module Module1
Sub Main()
Dim Li, Ls, op As Single
Do
marco()
menu()
op = Console.ReadLine
Select Case (op)
Case 1
Console.Clear()
marco()
Console.ForegroundColor = ConsoleColor.Green
Console.SetCursorPosition(37, 3)
Console.WriteLine("BUSCA")
Console.SetCursorPosition(3, 5)
Console.ForegroundColor = ConsoleColor.White
Busca(Li, Ls)
Console.Clear()
Case 2
Console.Clear()
marco()
Console.ForegroundColor = ConsoleColor.Magenta
Console.SetCursorPosition(34, 3)
Console.WriteLine("BISECCION")
Console.SetCursorPosition(3, 5)
Console.ForegroundColor = ConsoleColor.White
Bisecc(Li, Ls)
Console.Clear()
Case 3
Console.Clear()
marco()
Console.ForegroundColor = ConsoleColor.Red
Console.SetCursorPosition(36, 3)
Console.WriteLine("NEWTON")
Console.SetCursorPosition(3, 5)
Console.ForegroundColor = ConsoleColor.White
Newton(Li, Ls)
Console.Clear()
Case 4 = False
End Select
Loop While (op < 4)
End Sub
Sub marco()
Dim c, d As Integer
Console.ForegroundColor = ConsoleColor.Blue
For c = 1 To 78
Console.SetCursorPosition(c, 1)
Console.WriteLine("▼")
Console.SetCursorPosition(c, 23)
Console.WriteLine("▼")
Next
For d = 1 To 23
Console.SetCursorPosition(1, d)
Console.WriteLine("▼")
Console.SetCursorPosition(78, d)
Console.WriteLine("▼")
Next
End Sub
Sub menu()
Console.ForegroundColor = ConsoleColor.Cyan
Console.SetCursorPosition(33, 3)
Console.WriteLine("***RAICES***")
Console.ForegroundColor = ConsoleColor.Gray
Console.SetCursorPosition(3, 5)
Console.WriteLine("1. Buca intervalo.")
Console.SetCursorPosition(3, 7)
Console.WriteLine("2. Biseccion.")
Console.SetCursorPosition(3, 9)
Console.WriteLine("3. Newton.")
Console.SetCursorPosition(3, 11)
Console.WriteLine("4. FIN")
Console.SetCursorPosition(3, 13)
Console.Write("Escoger: ")
End Sub
Sub Busca(ByRef a As Single, ByRef b As Single)
Dim x As Single
x = 0
While (f(x) < 0)
x = x + 0.1
End While
a = x - 0.1
b = x
Console.WriteLine("El intervalo es:[{0},{1}]", a, b)
Console.ReadLine()
End Sub
Sub Bisecc(ByVal a As Single, ByVal b As Single)
Dim c As Single
While (b - a > 0.000001)
c = (a + b) / 2
If (f(a) * f(c) > 0) Then
a = c
Else
b = c
End If
End While
Console.WriteLine("El punto es: {0}", c)
Console.ReadLine()
End Sub
Sub Newton(ByVal a As Single, ByVal b As Single)
Dim d, xn As Single
d = 10
While (d > 0.0001)
xn = b - (f(b) / fd(b))
d = b - xn
b = xn
End While
Console.WriteLine("El punto es: {0}", xn)
Console.ReadLine()
End Sub
Function f(ByVal y As Single) As Single
Dim z As Single
z = y * y + 2 * y - 4
Return (z)
End Function
Function fd(ByVal y As Single) As Single
Dim h, l, d As Single
h = 1 / 100000
l = h + y
d = (f(l) - f(y)) / h
Return (d)
End Function
End Module