Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import scipy
- from scipy.misc import derivative
- x0 = 0.5
- x1 = 0.55
- x2 = 0.6
- x3 = 0.65
- x = 0.55
- def def_func(x):
- return 2*x - (1)/((x+2)*np.log(10))
- def func(x):
- return (x ** 2) - np.log10(x + 2)
- def lagrange3(x):
- return func(x0) * (x - x1) * (x - x2) * (x - x3) / ((x0 - x1) * (x0 - x2) * (x0 - x3)) + \
- func(x1) * (x - x0) * (x - x2) * (x - x3) / ((x1 - x0) * (x1 - x2) * (x1 - x3)) + \
- func(x2) * (x - x0) * (x - x1) * (x - x3) / ((x2 - x0) * (x2 - x1) * (x2 - x3)) + \
- func(x3) * (x - x0) * (x - x1) * (x - x2) / ((x3 - x0) * (x3 - x1) * (x3 - x2))
- def defferencial(x):
- return scipy.misc.derivative(lagrange3, x,
- dx=0.00000000001)
- print(defferencial(x))
- print(def_func(x))
- r = def_func(x) - defferencial(x)
- print(r)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement