Advertisement
qberik

Untitled

Oct 19th, 2022
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. from math import factorial
  2. from abc import ABC, abstractmethod
  3.  
  4.  
  5. class mathSolver( ABC ):
  6.  
  7. @abstractmethod
  8. def compute( self, x ):
  9. pass
  10.  
  11.  
  12. class sinTaylor( mathSolver ):
  13.  
  14. def compute(self, x):
  15. ans = 0
  16. persision = 10 # точность
  17.  
  18. for k in range(0,persision,1):
  19.  
  20. ans +=((-1)**k)*(x**(1+2*k))/factorial(1+2*k)
  21.  
  22. return ans
  23.  
  24.  
  25.  
  26.  
  27. a = sinTaylor()
  28. print( a.compute(3.14) )
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement