Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.99 KB | None | 0 0
  1. % Computer lab 2 & 3
  2. % Johan Larsson
  3. % Max Niia
  4.  
  5. function [ alpha, alphas ] = super_linearity(xi, r)
  6.     syms x;
  7.    
  8.     % The first and second derivate of the polynomial
  9.     xprim = diff(54*x^6 + 45*x^5 - 102*x^4 - 69*x^3 + 35*x^2 + 16*x - 4, x, 1);
  10.     xbis  = diff(54*x^6 + 45*x^5 - 102*x^4 - 69*x^3 + 35*x^2 + 16*x - 4, x, 2);
  11.    
  12.     % The value of the first and second derivative f'(r) and f''(r)
  13.     first = vpa(subs(xprim, x, r));
  14.     second = vpa(subs(xbis, x, r));
  15.     index = size(xi, 2) - 1;
  16.     index2 = index - 1;
  17.     e = abs(xi(index) - r);
  18.     e1 = abs(xi(index2) - r);
  19.     alphas = [];
  20.     for i = 1:size(xi, 2) - 2
  21.         e_i = abs(xi(i) - r);
  22.         e_i1 = abs(xi(i + 1) - r);
  23.         t_1 = (log(e_i1) + log(abs(second/(2*first))));
  24.         n_1 = (log(e_i) + log(abs(second/(2*first))));
  25.         alphas(i) = t_1/n_1;
  26.     end
  27.        
  28.     t = (log(e) + log(abs(second/(2*first))));
  29.     n = (log(e1) + log(abs(second/(2*first))));
  30.        
  31.     alpha = t/n;
  32. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement