daily pastebin goal
53%
SHARE
TWEET

Untitled

a guest Jan 11th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Pogorzelski Paweł Informatyka IO  Kolokwium nr2 B
  2. clear;
  3. clc;
  4. n=10;
  5. a_b=(-1:0.1:1);
  6. g=wspolczynnik_g(n, wezly1)
  7. ro=wspolczynnik_ro(n, wezly1)
  8. a=rownanie(g,ro)
  9. disp(n,"n=");
  10. disp(a_b,"(a,b)=");
  11. function out=wezly(n)
  12.     for i=0:n
  13.         out(i+1)=cos(((2*i+1)/2*(n+1))*%pi)
  14.     end
  15. function out = f(x, n)
  16.     for i = 0 : n - 1
  17.         out(n+1) = exp(x(i)) - (x(i) + 1)^2;
  18.     end
  19.     exp(e) = (x-1)^2;
  20. endfunction
  21. function g=licz(n, vx)
  22.     n=length(vx)-1
  23.     for j=0:2
  24.         for i=0:n
  25.             tmp(i+1)=vx(i+1)^j
  26.         end
  27.         g(j+1)=sum(tmp)
  28.     end
  29. endfunction
  30.  
  31. function ro=licz(n, vx)
  32.     n=length(vx)-1
  33.     for j=0:2
  34.         for i=0:n
  35.             tmp(i+1)=f(vx(i+1))*(vx(i+1)^j)
  36.         end
  37.         rho(j+1)=sum(tmp)
  38.     end
  39. endfunction
  40. function a=rownania(g, ro)
  41.     a(1)=(-g(3)*ro(1)+g(2)*ro(2))/(g(2)*g(2)-g(1)*g(3));
  42.     a(2)=(-g(2)*ro(1)-g(1)*ro(2))/(g(2)*g(2)-g(1)*g(3));
  43. endfunction
  44. function y=F(x, va)
  45.     y=va(1) + va(2)*x
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top