Your SlideShare is downloading. ×
Ejercicios Scilab Completo
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Ejercicios Scilab Completo

20,313
views

Published on

ejercicios con los resultados, excepto el punto de la falsa posición porque me genera un error del programa

ejercicios con los resultados, excepto el punto de la falsa posición porque me genera un error del programa


3 Comments
4 Likes
Statistics
Notes
  • el de punto fijo te da un valor extraño
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • gracias culo
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • excelent
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
20,313
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
753
Comments
3
Likes
4
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Ricardo Adolfo Grandas Código: 2305014 Ejercicios en Scilab 1) Método de Biseccion function y=f(x) y=-12.4+10*(0.5*%pi-asin(x/1)-x*(1-x**2)**0.5); endfunction function xr=biseccion(xai,xbi,tol) i=1; ea(1)=100; if f(xai)*f(xbi) < 0 xa(1)=xai; xb(1)=xbi; xr(1)=(xa(1)+xb(1))/2; printf('It.tt Xatt Xbtt Xrtt f(Xr)t Error n'); printf('%2d t %11.7f t %11.7f t %11.7f t %11.7f n',i,xa(i),xb(i),xr(i),f(xr(i))); while abs(ea(i)) >= tol if f(xa(i))*f(xr(i))< 0 xa(i+1)=xa(i); xb(i+1)=xr(i); end if f(xa(i))*f(xr(i))> 0 xa(i+1)=xr(i); xb(i+1)=xb(i); end xr(i+1)=(xa(i+1)+xb(i+1))/2; ea(i+1)=abs((xr(i+1)-xr(i))/(xr(i+1))); printf('%2d t %11.7f t %11.7f t %11.7f t %11.7f t %7.6f n',i+1,xa(i+1),xb(i+1),xr(i+1),f(xr(i+1)),ea(i+1)); i=i+1; end else printf('No existe una raíz en ese intervalo'); end endfunction
  • 2. 2) Método Newton-Raphson function y=f(x) y=2*x**3+x-1; endfunction function y=df(x) y=6*x**2+1; endfunction function x=newtonraphson(x0,tol); i=1; ea(1)=100; x(1)=x0; while abs(ea(i))>=tol; x(i+1)=x(i)-f(x(i))/df(x(i)); ea(i+1)=abs((x(i+1)-x(i))/x(i+1)); i=i+1; end printf(' i t X(i) Error aprox (i) n'); for j=1:i; printf('%2d t %11.7f t %7.6f n',j-1,x(j),ea(j)); end endfunction
  • 3. 3) Iteración Punto Fijo function y=g(x) y=300-80.425*x+201.0625*(1-exp(-(0.1)*x/0.25)); endfunction function x=puntofijo(x0,tol) i=1; ea(1)=100; x(1)=x0; while abs(ea(i))>=tol, x(i+1) = g(x(i)); ea(i+1) = abs((x(i+1)-x(i))/x(i+1)); i=i+1; end printf(' i t X(i) Error aprox (i) n'); for j=1:i; printf('%2d t %11.7f t %7.3f n',j-1,x(j),ea(j)); end endfunction
  • 4. 4) a- Newton function y=f(x) y=4*cos(x)-exp(x); endfunction function y=df(x) y=-4*sin(x)-exp(x); endfunction function x=newtonraphson(x0,tol); i=1; ea(1)=100; x(1)=x0; while abs(ea(i))>=tol; x(i+1)=x(i)-f(x(i))/df(x(i)); ea(i+1)=abs((x(i+1)-x(i))/x(i+1)); i=i+1; end printf(' i t X(i) Error aprox (i) n'); for j=1:i; printf('%2d t %11.7f t %7.6f n',j-1,x(j),ea(j)); end endfunction
  • 5. b- Secante function y=f(x) y=4*cos(x)-exp(x); endfunction function x = secante(x0,x1,tol) j=2; i=1; x(1)=x0; x(2)=x1; ea(i)=100; while abs(ea(i))>=tol x(j+1)=(x(j-1)*f(x(j))-x(j)*f(x(j-1)))/(f(x(j))-f(x(j-1))); ea(i+1)=abs((x(j+1)-x(j))/x(j+1)); j=j+1; i=i+1; end printf(' i tt x(i) t Error aprox (i) n'); printf('%2d t %11.7f t n',0,x(1)); for k=2:j; printf('%2d t %11.7f t %7.3f n',k-1,x(k),ea(k-1)); end endfunction
  • 6. 5) a- Secante function y=f(x) y=x**2-6; endfunction function x = secante(x0,x1,tol) j=2; i=1; x(1)=x0; x(2)=x1; ea(i)=100; while abs(ea(i))>=tol x(j+1)=(x(j-1)*f(x(j))-x(j)*f(x(j-1)))/(f(x(j))-f(x(j-1))); ea(i+1)=abs((x(j+1)-x(j))/x(j+1)); j=j+1; i=i+1; end printf(' i tt x(i) t Error aprox (i) n'); printf('%2d t %11.7f t n',0,x(1)); for k=2:j; printf('%2d t %11.7f t %7.3f n',k-1,x(k),ea(k-1)); end endfunction
  • 7. b- Falsa Posición function y=f(x) y=x**2-6; endfunction function xr=reglafalsa(xai,xbi,tol) i=1; ea(1)=100; if f(xai)*f(xbi) < 0 xa(1)=xai; xb(1)=xbi; xr(1)=xa(1)-f(xa(1))*(xb(1)-xa(1))/(f(xb(1))-f(xa(1))); printf('It. Xa Xb Xr f(Xr) Error aprox %n'); printf('%2d t %11.7f t %11.7f t %11.7ft %11.7f n',i,xa(i),xb(i),xr(i),f(xr(i))); while abs(ea(i))>=tol, if f(xa(i))*f(xr(i))< 0 xa(i+1)=xa(i); xb(i+1)=xr(i); end if f(xa(i))*f(xr(i))> 0 xa(1)=xr(i); xb(1)=xb(i); end xr(i+1)=xa(i+1)-f(xa(i+1))*(xb(i+1)-xa(i+1))/(f(xb(i+1))-f(xa(i+1))); ea(i+1)=abs((xr(i+1)-xr(i))/(xr(i+1))); printf('%2d t %11.7f t %11.7f t %11.7f t %11.7ft %7.3f n', i+1,xa(i+1),xb(i+1),xr(i+1),f(xr(i+1)),ea(i+1)); i=i+1; end else printf('No existe una raíz en ese intervalo'); end endfunction