Last active
April 29, 2017 23:22
-
-
Save Reflej0/97daef42826a914db1f2e0621138d631 to your computer and use it in GitHub Desktop.
Algoritmo de Newton Raphson de Cálculo Numérico en Scilab.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [raizaproximada, iteraciones] = newton(funcion, aproximacioninicial, Tolerancia, Iteracionesmaximas) | |
aprox= aproximacioninicial; | |
while 1 | |
raizaproximada = aprox - funcion(aprox)/numderivative(funcion, aprox); | |
errorabsoluto = abs((raizaproximada-aprox)/raizaproximada)*100; | |
aprox = raizaproximada; | |
iteraciones = iteraciones + 1; | |
if(errorabsoluto < Tolerancia | iteraciones == Iteracionesmaximas ) then | |
break | |
end | |
end | |
endfunction | |
//Datos | |
function y = primera(x) | |
y = %e^x + 2^-x + 2*cos(x) - 6; | |
endfunction | |
A = 1; | |
B = 2; | |
Tolerancia = 0.00001; | |
Iteracionesmaximas = 100; | |
[raizaproximada, iteraciones] = newton(primera, A-B, Tolerancia, Iteracionesmaximas) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment