handcalcs icon indicating copy to clipboard operation
handcalcs copied to clipboard

incorrect results when using forallpeople with handcalcs

Open MichalTFD opened this issue 2 years ago • 2 comments

The calculation result is incorrect when using sqrt with variables

from math import sqrt
import handcalcs.render
import forallpeople
%%render
rho_1 = 200 *kg/m**3
rho_2 = 600 *kg/m**3
aa =     (200 *kg/m**3 * 600 *kg/m**3)**(1/2)   # ok,                                   direct input
bb = sqrt(200 *kg/m**3 * 600 *kg/m**3)          # BAD,                      no units,   direct input
cc =     (rho_1*rho_2)**(1/2)                   # ok,                                   using variable
dd = sqrt(rho_1*rho_2)                          # BAD,                      no units,   using variable
ee = sqrt(rho_1.value*rho_2.value)              # ok,   no substitution,    no units,   using variable
ff = sqrt((rho_1*rho_2).value)                  # ok,   no substitution,    no units,   using variable

MichalTFD avatar Sep 14 '23 12:09 MichalTFD

#146

AlexGriffiths526 avatar Nov 07 '23 11:11 AlexGriffiths526

I have done some testing and found this is a problem with forallpeople rather than handcalcs. This issue has been raised on the forallpeople GitHub https://github.com/connorferster/forallpeople/issues/19) The issue has been closed with a workaround. Hope this helps.

AlexGriffiths526 avatar Nov 07 '23 14:11 AlexGriffiths526