symbolic icon indicating copy to clipboard operation
symbolic copied to clipboard

prevent "pi" or any selected symbol being used when evaluating statements, when calculating pi itself

Open goofyseeker311 opened this issue 3 years ago • 1 comments

somehow the below statement should not produce or use "pi" internally in its calculation, how to make a "prevent using list"

sympref digits 100;theta_O = vpa ('10^-100');sind(theta_O)*180/theta_O ans = (sym)

1.8e+102sin(5.555555555555555555555555555555555555555555555555555555555555555555555555555555555555555 555555555556e-103pi)

goofyseeker311 avatar Aug 18 '21 19:08 goofyseeker311

Another example:

sympref digits 64
a = sym(2) / 3
b = vpa(a)
c = b * pi
c = (sym) 0.6666666666666666666666666666666666666666666666666666666666666667⋅π

And as in @goofyseeker311's example, we probably expected that pi to muliple explicitly.

One way to force this is to wrap the result in vpa, as in:

vpa(c)
ans = (sym) 2.094395102393195492308428922186335256131446266250070547316629728

Trying this in the example given above:

>> Y = sind(theta_O)*180/theta_O
Y = (sym) 1.8e+102⋅sin(5.555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555556e-103⋅π)

>> vpa(Y)
ans = (sym) 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117068

>> vpa(Y) - pi
ans = (sym) 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117068 - π

>> vpa(ans)
ans = (sym) -2.868892801759637438498898060495711247819338484968719192807696702690606067300137497850281208367846969e-102

Not sure what could be easily done about this except trying to make upstream SymPy's Float to be more greedy about combining with other numbers.

cbm755 avatar Apr 10 '22 06:04 cbm755