EDIT: added assert
as suggested by Wrzlprmft, which does not raise any exception.
I have to write code with many expressions of type a**b
, under the following circumstances
import sympy as sp
a, b = sp.symbols('a,b', real=True, positive=True)
expr1 = a**b
expr2 = pow(a,b)
assert expr1 is expr2
What are the expected/possible differences between a**b
and pow(a,b)
?
(e.g., when simplifying, collecting, etc., expressions).
Should I expect possible wrong results in any case?
So far, I found none.
I don't think I would use the third argument of pow
as my bases will be real (exponents will typically be integers or ratios between one- or two-digit integers), so this or this are not relevant.
This or this are focused on comparisons with math.pow
, although some answers also include both **
and pow
in comparisons of performance, showing minor differences.
None of the questions / answers deal with sympy
.
If math.pow
or sympy.Pow
provide any advantage in any case, I welcome the clarifications.
I don't foresee I would perform heavy computations, so minor performance differences will likely not impact my use case.