SlideShare a Scribd company logo
1 of 9
Sary Vanessa lozano cód. 2306510

                       1. METODO DE BISECCION


function y=f(x)
y=-12.4+10*(0.5*%pi-asin(x/1)-x*(1-x**2)**0.5);
endfunction


function ax=biseccion(ax1i,ax2i,tol)
i=1;
er(1)=100;
if f(ax1i)*f(ax2i) < 0
     ax1(1)=ax1i;
     ax2(1)=ax2i;
     ax(1)=(ax1(1)+ax2(1))/2;
     printf('It.tt ax1tt aX2tt axtt f(ax)t Error n');
     printf('%2d t %11.7f t %11.7f t %11.7f t %11.7f
n',i,ax1(i),ax2(i),ax(i),f(ax(i)));
     while abs(er(i)) >= tol
        if f(ax1(i))*f(ax(i))< 0
            ax1(i+1)=ax1(i);
            ax2(i+1)=ax(i);
        end
        if f(ax1(i))*f(ax(i))> 0
            ax1(i+1)=ax(i);
            ax2(i+1)= ax2(i);
          end
        ax(i+1)=(ax1(i+1)+ax2(i+1))/2;
        er(i+1)=abs((ax(i+1)-ax(i))/(ax(i+1)));
        printf('%2d t %11.7f t %11.7f t %11.7f t %11.7f t %7.6f
n',i+1,ax1(i+1),ax2(i+1),ax(i+1),f(ax(i+1)),er(i+1));
        i=i+1;
    end
else
    printf('No existe una raíz en ese intervalo');
end
endfunction
METODO DE BISECCION
2. METODO DE N-R

function y=f(x)
y=2*x**3+x-1;
endfunction

function y=df(x)
y=6*x**2+1;
endfunction

function h=newtonraphson(h0,tole);
i=1;
er(1)=100;
h(1)=h0;
while abs(er(i))>=tol;
     h(i+1)=h(i)-f(h(i))/df(h(i));
     er(i+1)=abs((h(i+1)-h(i))/h(i+1));
     i=i+1;
end
printf(' i t        h(i)      Error aprox (i) n');
for j=1:i;
     printf('%2d t %11.7f t %7.6f n',j-1,x(j),er(j));
end
endfunction
3. PUNTO FIJO

function y=g(x)
y=300-80.425*x+201.0625*(1-2.718281828**(-(0.1)*x/0.25));
endfunction

function h=puntofijo(h0,tole)
i=1;
er(1)=100;
h(1)=h0;
while abs(er(i))>=tole,
     h(i+1) = g(h(i));
     er(i+1) = abs((h(i+1)-h(i))/h(i+1));
     i=i+1;
end
printf(' i t       h(i)       Error aprox (i) n');
for j=1:i;
     printf('%2d t %11.7f t %7.3f n',j-1,h(j),er(j));
end
endfunction
4a.METODO DE NEWTON


function y=f(x)
y=4*cos(x)-2.718281828**(x);
endfunction

function y=df(x)
y=-4*sin(x)-2.718281828**(x);
endfunction

function h=newtonraphson(h0,tole);
i=1;
er(1)=100;
h(1)=h0;
while abs(er(i))>=tole;
     h(i+1)=h(i)-f(h(i))/df(h(i));
     er(i+1)=abs((h(i+1)-h(i))/h(i+1));
     i=i+1;
end
printf(' i t        h(i)      Error aprox (i) n');
for j=1:i;
     printf('%2d t %11.7f t %7.6f n',j-1,h(j),er(j));
end
endfunction
4b.METODO DE LA SECANTE
function y=f(x)
y=4*cos(x)-2.718281828**(x);
endfunction

function h = secante(h0,h1,tole)
j=2;
i=1;
h(1)=h0;
h(2)=h1;
er(i)=100;
while abs(er(i))>=tole
    h(j+1)=(h(j-1)*f(h(j))-h(j)*f(h(j-1)))/(f(h(j))-f(h(j-1)));
    er(i+1)=abs((h(j+1)-h(j))/h(j+1));
    j=j+1;
    i=i+1;
end

printf(' i tt h(i) t Error aprox (i) n');
printf('%2d t %11.7f t n',0,h(1));

for k=2:j;
    printf('%2d t %11.7f t %7.3f n',k-1,h(k),er(k-1));
end

endfunction




                       5a.METODO DE LA SECANTE


function y=f(x)
y=x**2-6;
endfunction
function h = secante(h0,h1,tole)
j=2;
i=1;
h(1)=h0;
h(2)=h1;
er(i)=100;
while abs(er(i))>=tole
    h(j+1)=(h(j-1)*f(h(j))-h(j)*f(h(j-1)))/(f(h(j))-f(h(j-1)));
    er(i+1)=abs((h(j+1)-h(j))/h(j+1));
    j=j+1;
    i=i+1;
end

printf(' i tt h(i) t Error aprox (i) n');
printf('%2d t %11.7f t n',0,h(1));

for k=2:j;
    printf('%2d t %11.7f t %7.3f n',k-1,h(k),er(k-1));
end

endfunction




                  5b.METODO DE LA FALSA POSICION




function y=f(x)
y=(x^2) -6;
endfunction


function ax=reglafalsa(ax1i,ax2i,tole)
i=1;
er(1)=100;
if f(ax1i)*f(ax2i) < 0
     ax1(1)=ax1i;
     ax2(1)=ax2i;
     ax(1)=ax1(1)-f(ax1(1))*(ax2(1)-ax1(1))/(f(ax2(1))-f(ax1(1)));
     printf('It.                aX1          aX2            aX
f(aX)               Error aprox %n');
     printf('%2d t %11.7f t %11.7f t %11.7ft %11.7f
n',i,ax1(i),ax2(i),ax(i),f(ax(i)));
     while abs(er(i))>=tole,
        if f(ax1(i))*f(ax(i))< 0
            ax1(i+1)=ax1(i);
            ax2(i+1)=ax(i);
        end
        if f(ax1(i))*f(ax(i))> 0
            ax1(1)=ax(i);
            ax2(1)=ax2(i);
          end
        ax(i+1)=ax1(i+1)-f(ax1(i+1))*(ax2(i+1)-ax1(i+1))/(f(ax2(i+1))-
f(ax1(i+1)));
         er(i+1)=abs((ax(i+1)-ax(i))/(ax(i+1)));
        printf('%2d t %11.7f t %11.7f t %11.7f t %11.7ft %7.3f
n', i+1,ax1(i+1),ax2(i+1),ax(i+1),f(ax(i+1)),er(i+1));
        i=i+1;
    end
else
    printf('No existe una raíz en ese intervalo');
end
endfunction
5c. La raíz de 6 = 2.449489742
Como se puede notar en los dos métodos anteriores se adquiere un alto grado de
a proximidad a la raíz de 6.pero haciendo una comparación entre ambos
podemos decir que el mas se acerca es el método de la secante.

More Related Content

What's hot

Quinto Punto Parte A
Quinto Punto Parte AQuinto Punto Parte A
Quinto Punto Parte A
gustavo206
 
Quinto Punto Parte B
Quinto Punto Parte BQuinto Punto Parte B
Quinto Punto Parte B
gustavo206
 
FishersEquationCode
FishersEquationCodeFishersEquationCode
FishersEquationCode
Talal Tahir
 
Reverse Engineering: C++ "for" operator
Reverse Engineering: C++ "for" operatorReverse Engineering: C++ "for" operator
Reverse Engineering: C++ "for" operator
erithion
 
型理論 なんて自分には関係ないと思っているあなたへ
型理論 なんて自分には関係ないと思っているあなたへ型理論 なんて自分には関係ないと思っているあなたへ
型理論 なんて自分には関係ないと思っているあなたへ
Yusuke Matsushita
 

What's hot (17)

Quinto Punto Parte A
Quinto Punto Parte AQuinto Punto Parte A
Quinto Punto Parte A
 
Quinto Punto Parte B
Quinto Punto Parte BQuinto Punto Parte B
Quinto Punto Parte B
 
Primer Punto
Primer PuntoPrimer Punto
Primer Punto
 
Blocks+gcd入門
Blocks+gcd入門Blocks+gcd入門
Blocks+gcd入門
 
Throttle and Debounce Patterns in Web Apps
Throttle and Debounce Patterns in Web AppsThrottle and Debounce Patterns in Web Apps
Throttle and Debounce Patterns in Web Apps
 
Data Structure - 2nd Study
Data Structure - 2nd StudyData Structure - 2nd Study
Data Structure - 2nd Study
 
portabellocoaching
portabellocoachingportabellocoaching
portabellocoaching
 
Session07 recursion
Session07 recursionSession07 recursion
Session07 recursion
 
Wap to implement bitwise operators
Wap to implement bitwise operatorsWap to implement bitwise operators
Wap to implement bitwise operators
 
JavaScript Gotchas
JavaScript GotchasJavaScript Gotchas
JavaScript Gotchas
 
Avl tree
Avl treeAvl tree
Avl tree
 
FishersEquationCode
FishersEquationCodeFishersEquationCode
FishersEquationCode
 
Reverse Engineering: C++ "for" operator
Reverse Engineering: C++ "for" operatorReverse Engineering: C++ "for" operator
Reverse Engineering: C++ "for" operator
 
Javascript Common Mistakes
Javascript Common MistakesJavascript Common Mistakes
Javascript Common Mistakes
 
Tabla de _derivadas
Tabla de _derivadasTabla de _derivadas
Tabla de _derivadas
 
Tabla derivadas
Tabla derivadasTabla derivadas
Tabla derivadas
 
型理論 なんて自分には関係ないと思っているあなたへ
型理論 なんて自分には関係ないと思っているあなたへ型理論 なんて自分には関係ないと思っているあなたへ
型理論 なんて自分には関係ないと思っているあなたへ
 

Viewers also liked (8)

好生意专业店铺服务在阿里软件、淘宝开放平台的1年
好生意专业店铺服务在阿里软件、淘宝开放平台的1年好生意专业店铺服务在阿里软件、淘宝开放平台的1年
好生意专业店铺服务在阿里软件、淘宝开放平台的1年
 
PDA ARS tool with image capabilities
PDA ARS tool with image capabilitiesPDA ARS tool with image capabilities
PDA ARS tool with image capabilities
 
SNW Fall 2009
SNW Fall 2009SNW Fall 2009
SNW Fall 2009
 
SNW Spring 10 Presentation
SNW Spring 10 PresentationSNW Spring 10 Presentation
SNW Spring 10 Presentation
 
CatalystBuilder Introduction 2015.08.31
CatalystBuilder Introduction 2015.08.31CatalystBuilder Introduction 2015.08.31
CatalystBuilder Introduction 2015.08.31
 
0844 Number
0844 Number0844 Number
0844 Number
 
Eu somii newsletter 2014 web
Eu somii newsletter 2014 webEu somii newsletter 2014 web
Eu somii newsletter 2014 web
 
Parigi
ParigiParigi
Parigi
 

Similar to Sary

関数潮流(Function Tendency)
関数潮流(Function Tendency)関数潮流(Function Tendency)
関数潮流(Function Tendency)
riue
 
Intro to Functional Programming Workshop (code4lib)
Intro to Functional Programming Workshop (code4lib)Intro to Functional Programming Workshop (code4lib)
Intro to Functional Programming Workshop (code4lib)
Will Kurt
 

Similar to Sary (20)

matlab codes.pdf
matlab codes.pdfmatlab codes.pdf
matlab codes.pdf
 
chap 2 Ex#1.1
chap 2 Ex#1.1chap 2 Ex#1.1
chap 2 Ex#1.1
 
Es84
Es84Es84
Es84
 
From Javascript To Haskell
From Javascript To HaskellFrom Javascript To Haskell
From Javascript To Haskell
 
Numerical Method Assignment
Numerical Method AssignmentNumerical Method Assignment
Numerical Method Assignment
 
A Course in Fuzzy Systems and Control Matlab Chapter Three
A Course in Fuzzy Systems and Control Matlab Chapter ThreeA Course in Fuzzy Systems and Control Matlab Chapter Three
A Course in Fuzzy Systems and Control Matlab Chapter Three
 
Solution Manual : Chapter - 07 Exponential, Logarithmic and Inverse Trigonome...
Solution Manual : Chapter - 07 Exponential, Logarithmic and Inverse Trigonome...Solution Manual : Chapter - 07 Exponential, Logarithmic and Inverse Trigonome...
Solution Manual : Chapter - 07 Exponential, Logarithmic and Inverse Trigonome...
 
Computer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsComputer Graphics Lab File C Programs
Computer Graphics Lab File C Programs
 
関数潮流(Function Tendency)
関数潮流(Function Tendency)関数潮流(Function Tendency)
関数潮流(Function Tendency)
 
Introductory RxJava
Introductory RxJavaIntroductory RxJava
Introductory RxJava
 
The Moore-Spiegel Oscillator
The Moore-Spiegel OscillatorThe Moore-Spiegel Oscillator
The Moore-Spiegel Oscillator
 
Go: It's Not Just For Google
Go: It's Not Just For GoogleGo: It's Not Just For Google
Go: It's Not Just For Google
 
Numerical Methods in C
Numerical Methods in CNumerical Methods in C
Numerical Methods in C
 
BCSL 058 solved assignment
BCSL 058 solved assignmentBCSL 058 solved assignment
BCSL 058 solved assignment
 
Assignment on Numerical Method C Code
Assignment on Numerical Method C CodeAssignment on Numerical Method C Code
Assignment on Numerical Method C Code
 
Math - Operations on Functions, Kinds of Functions
Math - Operations on Functions, Kinds of FunctionsMath - Operations on Functions, Kinds of Functions
Math - Operations on Functions, Kinds of Functions
 
DataStructures notes
DataStructures notesDataStructures notes
DataStructures notes
 
バイオインフォ分野におけるtidyなデータ解析の最新動向
バイオインフォ分野におけるtidyなデータ解析の最新動向バイオインフォ分野におけるtidyなデータ解析の最新動向
バイオインフォ分野におけるtidyなデータ解析の最新動向
 
Numerical Algorithm for a few Special Functions
Numerical Algorithm for a few Special FunctionsNumerical Algorithm for a few Special Functions
Numerical Algorithm for a few Special Functions
 
Intro to Functional Programming Workshop (code4lib)
Intro to Functional Programming Workshop (code4lib)Intro to Functional Programming Workshop (code4lib)
Intro to Functional Programming Workshop (code4lib)
 

Recently uploaded

Pakistani Call girls in Deira 0567006274 Deira Call girls
Pakistani Call girls in Deira 0567006274 Deira Call girlsPakistani Call girls in Deira 0567006274 Deira Call girls
Pakistani Call girls in Deira 0567006274 Deira Call girls
Monica Sydney
 
Deira Call girl agency 0567006274 Call girls in Deira
Deira Call girl agency 0567006274 Call girls in DeiraDeira Call girl agency 0567006274 Call girls in Deira
Deira Call girl agency 0567006274 Call girls in Deira
Monica Sydney
 
Haridwar Call Girls, 8699214473 Hot Girls Service Haridwar
Haridwar Call Girls, 8699214473 Hot Girls Service HaridwarHaridwar Call Girls, 8699214473 Hot Girls Service Haridwar
Haridwar Call Girls, 8699214473 Hot Girls Service Haridwar
ranekokila
 
Dubai Call girls Service 0524076003 Call girls in Dubai
Dubai Call girls Service 0524076003 Call girls in DubaiDubai Call girls Service 0524076003 Call girls in Dubai
Dubai Call girls Service 0524076003 Call girls in Dubai
Monica Sydney
 

Recently uploaded (20)

Call Girls Belonia Just Call 📞 8617370543 Top Class Call Girl Service Available
Call Girls Belonia Just Call 📞 8617370543 Top Class Call Girl Service AvailableCall Girls Belonia Just Call 📞 8617370543 Top Class Call Girl Service Available
Call Girls Belonia Just Call 📞 8617370543 Top Class Call Girl Service Available
 
Call Girls South Tripura Just Call 8617370543 Top Class Call Girl Service Ava...
Call Girls South Tripura Just Call 8617370543 Top Class Call Girl Service Ava...Call Girls South Tripura Just Call 8617370543 Top Class Call Girl Service Ava...
Call Girls South Tripura Just Call 8617370543 Top Class Call Girl Service Ava...
 
Pakistani Call girls in Deira 0567006274 Deira Call girls
Pakistani Call girls in Deira 0567006274 Deira Call girlsPakistani Call girls in Deira 0567006274 Deira Call girls
Pakistani Call girls in Deira 0567006274 Deira Call girls
 
Satara call girl 8617370543♥️ call girls in satara escort service
Satara call girl 8617370543♥️ call girls in satara escort serviceSatara call girl 8617370543♥️ call girls in satara escort service
Satara call girl 8617370543♥️ call girls in satara escort service
 
Deira Call girl agency 0567006274 Call girls in Deira
Deira Call girl agency 0567006274 Call girls in DeiraDeira Call girl agency 0567006274 Call girls in Deira
Deira Call girl agency 0567006274 Call girls in Deira
 
Bhubaneswar🌹Call Girls Rasulgada ❤Komal 9777949614 💟 Full Trusted CALL GIRLS ...
Bhubaneswar🌹Call Girls Rasulgada ❤Komal 9777949614 💟 Full Trusted CALL GIRLS ...Bhubaneswar🌹Call Girls Rasulgada ❤Komal 9777949614 💟 Full Trusted CALL GIRLS ...
Bhubaneswar🌹Call Girls Rasulgada ❤Komal 9777949614 💟 Full Trusted CALL GIRLS ...
 
Call Girls Bijnor Just Call 8617370543 Top Class Call Girl Service Available
Call Girls Bijnor  Just Call 8617370543 Top Class Call Girl Service AvailableCall Girls Bijnor  Just Call 8617370543 Top Class Call Girl Service Available
Call Girls Bijnor Just Call 8617370543 Top Class Call Girl Service Available
 
Haridwar Call Girls, 8699214473 Hot Girls Service Haridwar
Haridwar Call Girls, 8699214473 Hot Girls Service HaridwarHaridwar Call Girls, 8699214473 Hot Girls Service Haridwar
Haridwar Call Girls, 8699214473 Hot Girls Service Haridwar
 
Hire 💕 8617370543 Auraiya Call Girls Service Call Girls Agency
Hire 💕 8617370543 Auraiya Call Girls Service Call Girls AgencyHire 💕 8617370543 Auraiya Call Girls Service Call Girls Agency
Hire 💕 8617370543 Auraiya Call Girls Service Call Girls Agency
 
Hire 💕 8617370543 Khalilabad Call Girls Service Call Girls Agency
Hire 💕 8617370543 Khalilabad Call Girls Service Call Girls AgencyHire 💕 8617370543 Khalilabad Call Girls Service Call Girls Agency
Hire 💕 8617370543 Khalilabad Call Girls Service Call Girls Agency
 
Bhubaneswar🌹Call Girls Chandrashekharpur ❤Komal 9777949614 💟 Full Trusted CAL...
Bhubaneswar🌹Call Girls Chandrashekharpur ❤Komal 9777949614 💟 Full Trusted CAL...Bhubaneswar🌹Call Girls Chandrashekharpur ❤Komal 9777949614 💟 Full Trusted CAL...
Bhubaneswar🌹Call Girls Chandrashekharpur ❤Komal 9777949614 💟 Full Trusted CAL...
 
Top IPTV Subscription Service to Stream Your Favorite Shows in 2024.pdf
Top IPTV Subscription Service to Stream Your Favorite Shows in 2024.pdfTop IPTV Subscription Service to Stream Your Favorite Shows in 2024.pdf
Top IPTV Subscription Service to Stream Your Favorite Shows in 2024.pdf
 
Genuine 8617370543 Hot and Beautiful 💕 Gomati Escorts call Girls
Genuine 8617370543 Hot and Beautiful 💕 Gomati Escorts call GirlsGenuine 8617370543 Hot and Beautiful 💕 Gomati Escorts call Girls
Genuine 8617370543 Hot and Beautiful 💕 Gomati Escorts call Girls
 
Deira call girls 0507330913 Call girls in Deira
Deira call girls 0507330913  Call girls in DeiraDeira call girls 0507330913  Call girls in Deira
Deira call girls 0507330913 Call girls in Deira
 
Badshah Nagar ] Call Girls Service Lucknow | Starting ₹,5K To @25k with A/C 9...
Badshah Nagar ] Call Girls Service Lucknow | Starting ₹,5K To @25k with A/C 9...Badshah Nagar ] Call Girls Service Lucknow | Starting ₹,5K To @25k with A/C 9...
Badshah Nagar ] Call Girls Service Lucknow | Starting ₹,5K To @25k with A/C 9...
 
Deira Call girls 0507330913 Call girls in Deira
Deira Call girls 0507330913 Call girls in DeiraDeira Call girls 0507330913 Call girls in Deira
Deira Call girls 0507330913 Call girls in Deira
 
Hire 💕 8617370543 Kushinagar Call Girls Service Call Girls Agency
Hire 💕 8617370543 Kushinagar Call Girls Service Call Girls AgencyHire 💕 8617370543 Kushinagar Call Girls Service Call Girls Agency
Hire 💕 8617370543 Kushinagar Call Girls Service Call Girls Agency
 
Call Girls In Amreli Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service Enjoy...
Call Girls In Amreli Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service Enjoy...Call Girls In Amreli Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service Enjoy...
Call Girls In Amreli Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service Enjoy...
 
Call girls Service in Deira 0507330913 Deira Call girls
Call girls Service in Deira 0507330913 Deira Call girlsCall girls Service in Deira 0507330913 Deira Call girls
Call girls Service in Deira 0507330913 Deira Call girls
 
Dubai Call girls Service 0524076003 Call girls in Dubai
Dubai Call girls Service 0524076003 Call girls in DubaiDubai Call girls Service 0524076003 Call girls in Dubai
Dubai Call girls Service 0524076003 Call girls in Dubai
 

Sary

  • 1. Sary Vanessa lozano cód. 2306510 1. METODO DE BISECCION function y=f(x) y=-12.4+10*(0.5*%pi-asin(x/1)-x*(1-x**2)**0.5); endfunction function ax=biseccion(ax1i,ax2i,tol) i=1; er(1)=100; if f(ax1i)*f(ax2i) < 0 ax1(1)=ax1i; ax2(1)=ax2i; ax(1)=(ax1(1)+ax2(1))/2; printf('It.tt ax1tt aX2tt axtt f(ax)t Error n'); printf('%2d t %11.7f t %11.7f t %11.7f t %11.7f n',i,ax1(i),ax2(i),ax(i),f(ax(i))); while abs(er(i)) >= tol if f(ax1(i))*f(ax(i))< 0 ax1(i+1)=ax1(i); ax2(i+1)=ax(i); end if f(ax1(i))*f(ax(i))> 0 ax1(i+1)=ax(i); ax2(i+1)= ax2(i); end ax(i+1)=(ax1(i+1)+ax2(i+1))/2; er(i+1)=abs((ax(i+1)-ax(i))/(ax(i+1))); printf('%2d t %11.7f t %11.7f t %11.7f t %11.7f t %7.6f n',i+1,ax1(i+1),ax2(i+1),ax(i+1),f(ax(i+1)),er(i+1)); i=i+1; end else printf('No existe una raíz en ese intervalo'); end endfunction
  • 3. 2. METODO DE N-R function y=f(x) y=2*x**3+x-1; endfunction function y=df(x) y=6*x**2+1; endfunction function h=newtonraphson(h0,tole); i=1; er(1)=100; h(1)=h0; while abs(er(i))>=tol; h(i+1)=h(i)-f(h(i))/df(h(i)); er(i+1)=abs((h(i+1)-h(i))/h(i+1)); i=i+1; end printf(' i t h(i) Error aprox (i) n'); for j=1:i; printf('%2d t %11.7f t %7.6f n',j-1,x(j),er(j)); end endfunction
  • 4. 3. PUNTO FIJO function y=g(x) y=300-80.425*x+201.0625*(1-2.718281828**(-(0.1)*x/0.25)); endfunction function h=puntofijo(h0,tole) i=1; er(1)=100; h(1)=h0; while abs(er(i))>=tole, h(i+1) = g(h(i)); er(i+1) = abs((h(i+1)-h(i))/h(i+1)); i=i+1; end printf(' i t h(i) Error aprox (i) n'); for j=1:i; printf('%2d t %11.7f t %7.3f n',j-1,h(j),er(j)); end endfunction
  • 5. 4a.METODO DE NEWTON function y=f(x) y=4*cos(x)-2.718281828**(x); endfunction function y=df(x) y=-4*sin(x)-2.718281828**(x); endfunction function h=newtonraphson(h0,tole); i=1; er(1)=100; h(1)=h0; while abs(er(i))>=tole; h(i+1)=h(i)-f(h(i))/df(h(i)); er(i+1)=abs((h(i+1)-h(i))/h(i+1)); i=i+1; end printf(' i t h(i) Error aprox (i) n'); for j=1:i; printf('%2d t %11.7f t %7.6f n',j-1,h(j),er(j)); end endfunction
  • 6. 4b.METODO DE LA SECANTE function y=f(x) y=4*cos(x)-2.718281828**(x); endfunction function h = secante(h0,h1,tole) j=2; i=1; h(1)=h0; h(2)=h1; er(i)=100; while abs(er(i))>=tole h(j+1)=(h(j-1)*f(h(j))-h(j)*f(h(j-1)))/(f(h(j))-f(h(j-1))); er(i+1)=abs((h(j+1)-h(j))/h(j+1)); j=j+1; i=i+1; end printf(' i tt h(i) t Error aprox (i) n'); printf('%2d t %11.7f t n',0,h(1)); for k=2:j; printf('%2d t %11.7f t %7.3f n',k-1,h(k),er(k-1)); end endfunction 5a.METODO DE LA SECANTE function y=f(x) y=x**2-6; endfunction
  • 7. function h = secante(h0,h1,tole) j=2; i=1; h(1)=h0; h(2)=h1; er(i)=100; while abs(er(i))>=tole h(j+1)=(h(j-1)*f(h(j))-h(j)*f(h(j-1)))/(f(h(j))-f(h(j-1))); er(i+1)=abs((h(j+1)-h(j))/h(j+1)); j=j+1; i=i+1; end printf(' i tt h(i) t Error aprox (i) n'); printf('%2d t %11.7f t n',0,h(1)); for k=2:j; printf('%2d t %11.7f t %7.3f n',k-1,h(k),er(k-1)); end endfunction 5b.METODO DE LA FALSA POSICION function y=f(x)
  • 8. y=(x^2) -6; endfunction function ax=reglafalsa(ax1i,ax2i,tole) i=1; er(1)=100; if f(ax1i)*f(ax2i) < 0 ax1(1)=ax1i; ax2(1)=ax2i; ax(1)=ax1(1)-f(ax1(1))*(ax2(1)-ax1(1))/(f(ax2(1))-f(ax1(1))); printf('It. aX1 aX2 aX f(aX) Error aprox %n'); printf('%2d t %11.7f t %11.7f t %11.7ft %11.7f n',i,ax1(i),ax2(i),ax(i),f(ax(i))); while abs(er(i))>=tole, if f(ax1(i))*f(ax(i))< 0 ax1(i+1)=ax1(i); ax2(i+1)=ax(i); end if f(ax1(i))*f(ax(i))> 0 ax1(1)=ax(i); ax2(1)=ax2(i); end ax(i+1)=ax1(i+1)-f(ax1(i+1))*(ax2(i+1)-ax1(i+1))/(f(ax2(i+1))- f(ax1(i+1))); er(i+1)=abs((ax(i+1)-ax(i))/(ax(i+1))); printf('%2d t %11.7f t %11.7f t %11.7f t %11.7ft %7.3f n', i+1,ax1(i+1),ax2(i+1),ax(i+1),f(ax(i+1)),er(i+1)); i=i+1; end else printf('No existe una raíz en ese intervalo'); end endfunction
  • 9. 5c. La raíz de 6 = 2.449489742 Como se puede notar en los dos métodos anteriores se adquiere un alto grado de a proximidad a la raíz de 6.pero haciendo una comparación entre ambos podemos decir que el mas se acerca es el método de la secante.