Advertisement
Guest User

Untitled

a guest
Nov 6th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Julia 0.95 KB | None | 0 0
  1. using Polynomials
  2.  
  3. data_P = Float64[1, -210.0, 20615.0,-1256850.0,
  4.       53327946.0, -1672280820.0, 40171771630.0, -756111184500.0,
  5.       11310276995381.0, -135585182899530.0,
  6.       1307535010540395.0, -10142299865511450.0,
  7.       63030812099294896.0, -311333643161390640.0,
  8.       1206647803780373360.0, -3599979517947607200.0,
  9.       8037811822645051776.0, -12870931245150988800.0,
  10.       13803759753640704000.0, -8752948036761600000.0,
  11.       2432902008176640000.0]
  12.  
  13. data_p = Float64[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
  14.  
  15. data_P = flipdim(data_P, 1)
  16. P_Poly = Poly(data_P)
  17. p_poly = poly(data_p)
  18. zero_places = roots(P_Poly)
  19. println(zero_places,"\n")
  20. zero_places = flipdim(zero_places, 1)
  21.  
  22. for i = 1:length(zero_places)
  23.     println("|P(z$(i))|:\t$(abs(polyval(P_Poly,zero_places[i])))")
  24.     println("|p(z$(i))|:\t$(abs(polyval(p_poly,zero_places[i])))")
  25.     println("|z$(i)-$(i)|: \t$(abs(zero_places[i] - i))\n")
  26. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement