Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Résout f(x)=0 pour x dans [a,b]
- il faut f(a) et f(b) de signes contraires
- */
- function m=dichotomie(f,a,b)
- while abs(a-b)>10^(-8)
- m=(a+b)/2
- if f(a)*f(m) < 0 then
- b=m
- else
- a=m
- end
- end
- m=(a+b)/2
- endfunction
- function y=base_lagrange(x)
- for i=1:length(x)
- a=x
- a(i)=[]
- p=poly(a,'x')
- p=p/horner(p,x(i))
- y(i)=p
- end
- endfunction
- function P=poly_lagrange(x,y)
- P=poly(0,'x','coeff')
- L=base_lagrange(x)
- for i=1:length(x)
- P=P+y(i)*L(i)
- end
- endfunction
- function y=derive(x,f)
- h=10**(-8)
- y=(feval(x+h,f)-feval(x,f))/h
- endfunction
- function y=tangente(f,x0,x)
- y=derive(x0,f)*(x-x0)+feval(x0,f)
- printf("y=%.1f(x-%.1f)+%.1f", derive(x0,f),x0,feval(x0,f))
- endfunction
- function u=suite1(f,u1,n)
- u=u1
- for i=1:n-1
- u(i+1)=f(u(i))
- end
- disp(u)
- clf
- plot(u,'*-r')
- xgrid(3)
- endfunction
- function n0=suite2(f,u0,l,eps)
- n0=0
- u=u1
- while abs(u-l)>eps
- n0=n0+1
- u=f(u)
- end
- endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement