Advertisement
regergr

Untitled

Nov 15th, 2020
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. import numpy as np
  2. import scipy
  3. from scipy.misc import derivative
  4.  
  5. x0 = 0.5
  6. x1 = 0.55
  7. x2 = 0.6
  8. x3 = 0.65
  9. x = 0.55
  10.  
  11.  
  12. def def_func(x):
  13. return 2*x - (1)/((x+2)*np.log(10))
  14.  
  15. def func(x):
  16. return (x ** 2) - np.log10(x + 2)
  17.  
  18.  
  19. def lagrange3(x):
  20. return func(x0) * (x - x1) * (x - x2) * (x - x3) / ((x0 - x1) * (x0 - x2) * (x0 - x3)) + \
  21. func(x1) * (x - x0) * (x - x2) * (x - x3) / ((x1 - x0) * (x1 - x2) * (x1 - x3)) + \
  22. func(x2) * (x - x0) * (x - x1) * (x - x3) / ((x2 - x0) * (x2 - x1) * (x2 - x3)) + \
  23. func(x3) * (x - x0) * (x - x1) * (x - x2) / ((x3 - x0) * (x3 - x1) * (x3 - x2))
  24.  
  25.  
  26. def defferencial(x):
  27. return scipy.misc.derivative(lagrange3, x,
  28. dx=0.00000000001)
  29.  
  30.  
  31. print(defferencial(x))
  32. print(def_func(x))
  33. r = def_func(x) - defferencial(x)
  34. print(r)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement