Advertisement
Rementai

Pochodna

Mar 16th, 2023
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.33 KB | None | 0 0
  1. import math
  2.  
  3. def derivative(f, x, h=0.0001):
  4.     return (f(x + h) - f(x)) / h
  5.  
  6. def square(x):
  7.     return x**2
  8.  
  9. print("Pochodna sin(x) w punkcie 1:", derivative(math.sin, 1))
  10. print("Pochodna sin(x) w punkcie 0:", derivative(math.sin, 0))
  11. print("Pochodna x^2 w punkcie 1 z przyrostem 0.00001:", derivative(square, 1, h=0.00001))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement