Documentos de Académico
Documentos de Profesional
Documentos de Cultura
RESULTADOS METODO DE LAGRANGE. Interpola 𝑓(𝑥) = 𝑒 para x=3.8 con polinomio de orden
2.
End Sub
RESULTADOS METODO DE NEWTON Interpola 𝑓(𝑥) = 𝑒 para x=3.8 con polinomio de orden 2.
CODIGO DE LLAMADO A PROCESOS PARA REALIZAR PASOS 1 A PASO 7
PARA ALGORITMOS METODOS DE NEWTON Y LAGRANGE. LUEGO DE
HACER PASOS DE 1 A 7 SE HACE LLAMADO AL PROCEDIMIENTO QUE
CALCULE POR EL RESPECTIVO METODO, SE PUEDE UTILIZAR UN
OPCION PARA ESCOGER POR CUAL METODO VA A RESOLVER.
RECORDAR QUE CADA METODO SE TRABAJA EN UNA HOJA APARTE.
AQUÍ LINEA Sheets("Lagrange").Activate
ACTIVA LA HOJA “Lagrange” PARA PROCESO DE LAGRANGE
Option Explicit
Sub interpolacion()
Sheets("Lagrange").Activate
Range("A5:Z32767").ClearContents
Call imprimirTitulos
'ENTRADA DE DATOS
'leer a,b,n_datos, xainterpolar y orden
elerror = 1
fila = 4
Call calcularAleatorios(n_datos,x,a,b,fila)
'LLAMADO A PROCESO PARA ORDENAR arreglo x() IMPRIMIR datos ordenados
en la columna 3
'ACTUALIZA LA FILA
fila = 4
'LLAMADO a proceso para calcular y almacenar valores para y(). Imprimir valores de
y() en la columna 4.
Call calcularfdx(n_datos,x,y,fila)
'IMPRIMIR a Pos
Call calculaPos1(Pos,Pos1)
'IMPRIMIR a Pos1
'ACTUALIZA LA FILA
fila = 5
valorV = f(xainterpolar)
Cells(7, 5).Value = valorV
End Sub
Sub calculaPos1(pos,pos1)
Select Case pos
Case 0 'first position
pos1 = 0
Case n_datos 'last position
pos1 = pos - orden
Case n_datos - orden To n_datos - 1 'any position between N-order and the one
before last
pos1 = n_datos - orden
Case Else 'any position in between
pos1 = pos - 1
End Select
End Sub
Sub imprimirTitulos()
Cells(1, 1).Value = "a"
Cells(2, 1).Value = "b"
Cells(3, 1).Value = "I"
Cells(3, 2).Value = "aleatorios"
Cells(3, 3).Value = "x(I)"
Cells(3, 4).Value = "y(I)"
Cells(1, 5).Value = "x a interpolar"
Cells(2, 5).Value = "orden polinomio"
Cells(3, 5).Value = "valor interpolado"
Cells(6, 5).Value = "Valor Verdadero"
Cells(9, 5).Value = "Error %"
Cells(3, 8).Value = "TABLAS DE DATOS DEPENDIENDO DEL ORDEN"
Cells(4, 8).Value = "i"
Cells(4, 9).Value = "xi(i)"
Cells(4, 10).Value = "yi(i)"
Cells(1, 7).Value = "Pos"
Cells(2, 7).Value = "Pos1"
Cells(1, 3).Value = "N:total datos"
End Sub
Function generaaletorio(a, b)
generaaletorio = (b - a) * Rnd() + a
End Function
Function f(x)
f = Exp(x)
End Function
Sub OrdenarBurbuja(VectorOriginal, n)
Dim Temp As Double, i As Integer, j As Integer
For i = 0 To n - 1
For j = i + 1 To n
If VectorOriginal(i) > VectorOriginal(j) Then
Temp = VectorOriginal(i)
VectorOriginal(i) = VectorOriginal(j)
VectorOriginal(j) = Temp
End If
Next j
Next i
End Sub
=============================