Advertisement
Guest User

Untitled

a guest
Jun 4th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Octave 0.43 KB | None | 0 0
  1. n = 3;
  2. a = -1;
  3. b = 1;
  4. function W = calculate_W(x,k)
  5. cheb3 = @(arg) 4*(arg^3)-3*arg;
  6. if(!k>=2)
  7.  disp("k problem")
  8. else
  9.   W = (x^k - (2^(1-k)) * cheb3(x));
  10. end
  11. endfunction
  12.  
  13. points = [-1,-0.5,0,0.5,1]
  14. points_result = points.^n
  15. points_poly_results = [];
  16. for i=1:size(points,2)
  17.   points_poly_results = [points_poly_results,calculate_W(points(i),n)];
  18. end
  19. points_poly_results
  20.  
  21. error = max(abs(points_result.-points_poly_results))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement