Estimating a simplex floating-point function of arbitrary precision

For a symbolic symbolic function, e.g.

x=symbols("x")
h=sin(x) 

when you call

h.subs(x, mpf('1.0000000000000000000000000000000000000000000001')) 

sympy returns a floating point number. The return value is not mpf.

Is there a convenient way to get sympy to evaluate symbolic standard functions (e.g., exponential and trigon functions) using arbitrary precision?

+4
source share
1 answer

To evaluate an expression, use expr.evalf()one that takes precision as the first argument (the default is 15). You can replace expressions with expr.evalf(prec, subs=subs_dict).

>>> sin(x).evalf(50, subs={x: Float('1.0')})
0.84147098480789650665250232163029899962256306079837
+4
source

Source: https://habr.com/ru/post/1623387/


All Articles