Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Pogorzelski Paweł Informatyka IO Kolokwium nr2 B
- clear;
- clc;
- n=10;
- a_b=(-1:0.1:1);
- g=wspolczynnik_g(n, wezly1)
- ro=wspolczynnik_ro(n, wezly1)
- a=rownanie(g,ro)
- disp(n,"n=");
- disp(a_b,"(a,b)=");
- function out=wezly(n)
- for i=0:n
- out(i+1)=cos(((2*i+1)/2*(n+1))*%pi)
- end
- function out = f(x, n)
- for i = 0 : n - 1
- out(n+1) = exp(x(i)) - (x(i) + 1)^2;
- end
- exp(e) = (x-1)^2;
- endfunction
- function g=licz(n, vx)
- n=length(vx)-1
- for j=0:2
- for i=0:n
- tmp(i+1)=vx(i+1)^j
- end
- g(j+1)=sum(tmp)
- end
- endfunction
- function ro=licz(n, vx)
- n=length(vx)-1
- for j=0:2
- for i=0:n
- tmp(i+1)=f(vx(i+1))*(vx(i+1)^j)
- end
- rho(j+1)=sum(tmp)
- end
- endfunction
- function a=rownania(g, ro)
- a(1)=(-g(3)*ro(1)+g(2)*ro(2))/(g(2)*g(2)-g(1)*g(3));
- a(2)=(-g(2)*ro(1)-g(1)*ro(2))/(g(2)*g(2)-g(1)*g(3));
- endfunction
- function y=F(x, va)
- y=va(1) + va(2)*x
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement