Advertisement
Guest User

Untitled

a guest
Nov 10th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Julia 1.44 KB | None | 0 0
  1.  
  2. using Polynomials
  3.  
  4. coefficients_array = [1, -210.0, 20615.0,-1256850.0,
  5.       53327946.0,-1672280820.0, 40171771630.0, -756111184500.0,
  6.       11310276995381.0, -135585182899530.0,
  7.       1307535010540395.0,     -10142299865511450.0,
  8.       63030812099294896.0,     -311333643161390640.0,
  9.       1206647803780373360.0,     -3599979517947607200.0,
  10.       8037811822645051776.0,      -12870931245150988800.0,
  11.       13803759753640704000.0,      -8752948036761600000.0,
  12.       2432902008176640000.0]
  13.  
  14. roots_array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
  15.  
  16. new_coefficients_array = [1, -210.0 - 2.0^-23, 20615.0,-1256850.0,
  17.       53327946.0,-1672280820.0, 40171771630.0, -756111184500.0,
  18.       11310276995381.0, -135585182899530.0,
  19.       1307535010540395.0,     -10142299865511450.0,
  20.       63030812099294896.0,     -311333643161390640.0,
  21.       1206647803780373360.0,     -3599979517947607200.0,
  22.       8037811822645051776.0,      -12870931245150988800.0,
  23.       13803759753640704000.0,      -8752948036761600000.0,
  24.       2432902008176640000.0]
  25.  
  26.  
  27. P = Poly(flipdim(coefficients_array, 1)) #flipdim because Poly takes coefficient from the lowest order, e. g. a_0, a_1, ...
  28. p = poly(roots_array)
  29.  
  30. P_roots = roots(P)
  31. p_roots = roots(p)
  32.  
  33. println("Roots for P(x): ", P_roots)
  34. println("Roots for p(x): ", p_roots)
  35.  
  36. println("Checking |P(z_k)|: ")
  37. for i = 1 : size(P_roots)[1]
  38.       println("P(",i,") = ", P(P_roots[i]))
  39. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement