0% found this document useful (0 votes)
57 views9 pages

Universidad Nacional de San Agustin: Facultad de Producción Y Servicios Escuela de Ingenieria Industrial

The document is a code module written in Visual Basic for calculating derivatives and other mathematical functions. It contains code for menus, functions to calculate derivatives of different equations like f(x)=x^2, f(x)=x^2+2x+4, and f(x)=x^3. It also contains code for calculating exponential, sine, and cosine functions within certain ranges. The code uses loops and selection statements to call the different mathematical functions and display outputs.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views9 pages

Universidad Nacional de San Agustin: Facultad de Producción Y Servicios Escuela de Ingenieria Industrial

The document is a code module written in Visual Basic for calculating derivatives and other mathematical functions. It contains code for menus, functions to calculate derivatives of different equations like f(x)=x^2, f(x)=x^2+2x+4, and f(x)=x^3. It also contains code for calculating exponential, sine, and cosine functions within certain ranges. The code uses loops and selection statements to call the different mathematical functions and display outputs.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

FACULTAD DE PRODUCCIÓN Y SERVICIOS

UNIVERSIDAD
ESCUELA DE INGENIERIA INDUSTRIAL
NACIONAL DE
SAN AGUSTIN

CURSO: PROGRAMACION Y METODOS NUMERICOS

DOCENTE: JUAN CARLOS TORREBLANCA

PERTENECE:

 APAZA CASA YUSET KARLA


 ARIAS GOMEZ ANDREA FARIDI
 MAMANI LOPEZ SONIA SOLEDAD

GRUPO: “STEVE JOBS”

2017
UNIVERSIDAD NACIONAL DE SAN AGUSTIN –AREQUIPA
FACULTAD DE INGENIERÍA DE PRODUCCIÓN Y SERVICIOS
ESCUELA PROFESIONAL DE INGENIERÍA INDUSTRIAL

MENU DE DERIVADAS:

Module Module1

Sub Main()
Console.Clear()
Dim opcion As Integer
Dim x As Single

Do
marco()
menu(opcion)
Select Case (opcion)
Case 1
Console.Clear()
For x = 1 To 2.1 Step 0.1
Console.Write("La derivada de {0} ={1}", x, d(x))
Console.ReadLine()
Next
Console.ReadLine()

Case 2
Console.Clear()
For x = 1 To 2 Step 0.1
Console.Write("La derivada de {0}={1}", x, d2(x))
Console.ReadLine()
Next
Case 3
Console.Clear()
For x = 1 To 2 Step 0.1
Console.Write("La derivada de {0}={1}", x, d3(x))
Console.ReadLine()
Next
Case 4
Console.Clear()
Console.Write("*******FIN********")
Console.ReadLine()

End Select
Console.Clear()
Loop While (opcion <= 4)

End Sub
Sub marco()
Dim c, d As Integer
For c = 0 To 79
Console.SetCursorPosition(c, 0)
Console.ForegroundColor = ConsoleColor.Yellow
Console.Write("*")
Console.SetCursorPosition(c, 23)
Console.ForegroundColor = ConsoleColor.Yellow
Console.Write("*")
Next
For d = 0 To 23

1
UNIVERSIDAD NACIONAL DE SAN AGUSTIN –AREQUIPA
FACULTAD DE INGENIERÍA DE PRODUCCIÓN Y SERVICIOS
ESCUELA PROFESIONAL DE INGENIERÍA INDUSTRIAL

Console.SetCursorPosition(0, d)
Console.ForegroundColor = ConsoleColor.Yellow
Console.Write("*")
Console.SetCursorPosition(79, d)
Console.ForegroundColor = ConsoleColor.Yellow
Console.Write("*")
Next
Console.ReadLine()
End Sub
Sub menu(ByRef opcion As Integer)
Console.ForegroundColor = ConsoleColor.Green
Console.SetCursorPosition(32, 2)
Console.Write(" DERIVADAS ")
Console.SetCursorPosition(1, 4)
Console.ForegroundColor = ConsoleColor.Red

Console.Write(" 1.F(X)=X2 ")


Console.SetCursorPosition(1, 5)
Console.ForegroundColor = ConsoleColor.Red
Console.Write(" 2.F(X)=X2+2X+4 ")
Console.SetCursorPosition(1, 6)
Console.ForegroundColor = ConsoleColor.Red
Console.Write(" 3.F(X)=X3 ")
Console.SetCursorPosition(1, 7)
Console.ForegroundColor = ConsoleColor.Red
Console.Write(" 4.FIN ")
Console.SetCursorPosition(1, 9)
Console.ForegroundColor = ConsoleColor.Red
Console.Write(" ESCOGER OPCION ")
opcion = Console.ReadLine
End Sub
Function d(ByVal x As Single) As Single
Dim der As Single, h As Single = 0.00001
der = (f(x + h) - f(x)) / h
Return (der)
End Function

Function f(ByVal y As Single)


Return (y * y)
End Function
Function d2(ByVal x As Single)
Dim der As Single, h As Single = 0.00001
der = (f2(x + h) - f2(x)) / h
Return (der)
End Function
Function f2(ByVal y As Single)
Return (y * y + 2 * y - 4)
End Function
Function d3(ByVal x As Single)
Dim der As Single, h As Single = 0.00001
der = (f3(x + h) - f3(x)) / h
Return (der)
End Function
Function f3(ByVal y As Single)
Return (y * y * y)
End Function

2
UNIVERSIDAD NACIONAL DE SAN AGUSTIN –AREQUIPA
FACULTAD DE INGENIERÍA DE PRODUCCIÓN Y SERVICIOS
ESCUELA PROFESIONAL DE INGENIERÍA INDUSTRIAL

End Module

3
UNIVERSIDAD NACIONAL DE SAN AGUSTIN –AREQUIPA
FACULTAD DE INGENIERÍA DE PRODUCCIÓN Y SERVICIOS
ESCUELA PROFESIONAL DE INGENIERÍA INDUSTRIAL

4
UNIVERSIDAD NACIONAL DE SAN AGUSTIN –AREQUIPA
FACULTAD DE INGENIERÍA DE PRODUCCIÓN Y SERVICIOS
ESCUELA PROFESIONAL DE INGENIERÍA INDUSTRIAL

2:

Module Module1
Sub Main()
Dim opcion As Integer
Dim x As Single
Do
marco()
menu(opcion)
Select Case (opcion)
Case 1
Console.Clear()
For x = 1 To 10 Step 1
Console.Write("e^{0} ={1}", x, sol(x))
Console.ReadLine()
Next
Console.ReadLine()

Case 2
Console.Clear()
For x = 45 To 60 Step 1
Console.Write("el seno de {0}={1}", x, sol(x))
Console.ReadLine()
Next
Console.ReadLine()
Case 3
Console.Clear()
For x = 45 To 60 Step 1
Console.Write("el coseno de {0}={1}", x, sol(x))
Console.ReadLine()
Next
Case 4
Console.Clear()
Console.Write("*******FIN********")
Console.ReadLine()

End Select
Console.Clear()
Loop While (opcion <= 4)
End Sub
Sub marco()
Dim c, d As Integer
For c = 0 To 79
Console.SetCursorPosition(c, 0)
Console.ForegroundColor = ConsoleColor.Magenta
Console.Write("*")
Console.SetCursorPosition(c, 23)
Console.ForegroundColor = ConsoleColor.Magenta
Console.Write("*")
Next
For d = 0 To 23
Console.SetCursorPosition(0, d)
Console.ForegroundColor = ConsoleColor.Magenta
Console.Write("*")
Console.SetCursorPosition(79, d)
Console.ForegroundColor = ConsoleColor.Magenta
Console.Write("*")

5
UNIVERSIDAD NACIONAL DE SAN AGUSTIN –AREQUIPA
FACULTAD DE INGENIERÍA DE PRODUCCIÓN Y SERVICIOS
ESCUELA PROFESIONAL DE INGENIERÍA INDUSTRIAL

Next
Console.ReadLine()
End Sub
Sub menu(ByRef opcion As Integer)
Console.SetCursorPosition(32, 2)
Console.Write(" EJERCICIOS ")
Console.SetCursorPosition(1, 4)
Console.Write(" 1.EXPONENCIAL ")
Console.SetCursorPosition(1, 5)
Console.Write(" 2.SENOS ")
Console.SetCursorPosition(1, 6)
Console.Write(" 3.COSENOS ")
Console.SetCursorPosition(1, 7)
Console.Write(" 4.FIN ")
Console.SetCursorPosition(1, 9)
Console.Write(" ESCOGER OPCION ")
opcion = Console.ReadLine
End Sub
Function sol(ByVal y As Single) As Single
Dim e, d, n As Single
e = 1
d = 1
For i = 1 To 10
e = e * i
n = Math.Pow(y, i)
d = d + n / e
Next
Return (d)
End Function
Function fact(ByVal n As Integer) As Long
Dim f As Long = 1
Dim i As Integer
For i = 1 To n
f = f * i
Next
Return f
End Function
Function a()
Dim seno As Integer = 0
Dim x, rad As Single
For x = 45 To 60 Step 1
rad = x * 3.1416 / 180
Dim signo As Integer = 1

Dim i As Integer
For i = 1 To 15 Step +2
seno = seno + signo * Math.Pow(x, i) / factorial(i)
signo = signo * -1
Next
Next
Return (seno)
End Function

Function factorial(ByVal n As Integer) As Long


Dim f As Long = 2
Dim i As Integer
For i = 2 To n

6
UNIVERSIDAD NACIONAL DE SAN AGUSTIN –AREQUIPA
FACULTAD DE INGENIERÍA DE PRODUCCIÓN Y SERVICIOS
ESCUELA PROFESIONAL DE INGENIERÍA INDUSTRIAL

f = f * i
Next
Return f
End Function
Function coseno(ByVal C As Double) As Double
Dim x As Single, S As Single = 1, cos As Single
Dim sig As Single = -1
Dim i As Integer
Dim e As Single
For i = 0 To 14 Step 2
e = 1
Console.ForegroundColor = ConsoleColor.Red
sig = sig * -1
cos = sig * (Math.Pow(x, i) / factorial(i))
S = S + cos
Next
Return S
End Function
End Module

7
UNIVERSIDAD NACIONAL DE SAN AGUSTIN –AREQUIPA
FACULTAD DE INGENIERÍA DE PRODUCCIÓN Y SERVICIOS
ESCUELA PROFESIONAL DE INGENIERÍA INDUSTRIAL

You might also like