Fix mypy errors for arithmetic analysis algorithms (#4053)

This commit is contained in:
Dhruv Manilawala
2020-12-23 15:22:43 +05:30
committed by GitHub
parent 2ff2ccbeec
commit ad5108d6a4
5 changed files with 90 additions and 60 deletions

View File

@ -4,11 +4,14 @@
# quickly find a good approximation for the root of a real-valued function
from decimal import Decimal
from math import * # noqa: F401, F403
from typing import Union
from sympy import diff
def newton_raphson(func: str, a: int, precision: int = 10 ** -10) -> float:
def newton_raphson(
func: str, a: Union[float, Decimal], precision: float = 10 ** -10
) -> float:
"""Finds root from the point 'a' onwards by Newton-Raphson method
>>> newton_raphson("sin(x)", 2)
3.1415926536808043