Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %Trimitem temele cu publish, in format html. Schimbam numele folderului in nume, grupa.
- %ex1.m
- syms x
- f = x^4 + 2*x^2-x-3;
- ezplot(f,[1,2]);
- fi2=sqrt((3+x-x.^4)/2);
- fi4=(3*x^4 + 2*x^2 + 3)/(4*x^3+4*x-1);
- figure(2);
- subplot(1,2,1);
- ezplot(fi2,[1,2]);
- subplot(1,2,2);
- ezplot(fi4,[1,2]);
- dfi4=diff(fi4);
- figure(3);
- ezplot(dfi4,[1,2]);
- fi4=inline(fi4,'x');
- xaprox=MetPunctFix(fi4,1.5,20);
- figure(1);
- hold on;
- plot(xaprox,subs(f,x,xaprox),'o');
- $MetPunctFix.m
- function [xaprox]=MetPunctFix(fi,x0,n)
- x(1)=x0;
- for k = 2:n
- x(k)=double(fi(x(k-1)));
- end
- xaprox=x(k)
- end
- %ex1 fara functie separata
- function Ex1
- syms x
- f = x^4 + 2*x^2-x-3;
- ezplot(f,[1,2]);
- fi2=sqrt((3+x-x.^4)/2);
- fi4=(3*x^4 + 2*x^2 + 3)/(4*x^3+4*x-1);
- figure(2);
- subplot(1,2,1);
- ezplot(fi2,[1,2]);
- subplot(1,2,2);
- ezplot(fi4,[1,2]);
- dfi4=diff(fi4);
- figure(3);
- ezplot(dfi4,[1,2]);
- fi4=inline(fi4,'x');
- xaprox=MetPunctFix(fi4,1.5,20);
- figure(1);
- ezplot(f,[1,2]);
- hold on;
- f=inline(f,'x');
- plot(xaprox,f(xaprox),'o');
- function [xaprox]=MetPunctFix(fi,x0,n)
- x(1)=x0;
- for k = 2:n
- x(k)=double(fi(x(k-1)));
- end
- xaprox=x(k)
- end
- end
- %ex2
- syms x
- f=x^3-2*x^2-5
- eps=10^(-4)
- ezplot(f,[1,4]);
- df=diff(f);
- f=inline(f,'x');
- df=inline(df,'x');
- xaprox=MetNewton(f,df,2,eps);
- hold on;
- plot(xaprox,f(xaprox),'o')
Add Comment
Please, Sign In to add comment