There seems to be no equivalent for cosd, sind in sympy (ie cosine and sine for arguments in degrees). Is there any simple way to implement those functions ?
For numpy, I did :
numpy.cosd = lambda x : numpy.cos( numpy.deg2rad(x) )
Something like :
sympy.cosd = lambda x : sympy.cos( sympy.pi/180*x )
works for evaluation, but the expression is printed as :
cos(pi*x/180)
which is not great for readability (I have complicated expression due to 3D coordinates changes). Is there any way to create a sympy.cosd function which evaluates cos(pi/180 * x) but prints cosd(x)?
pi/180warts when working in degrees. It's better to work in radians and avoid degrees entirely -- or convert to degrees at the end if you absolutely must. - unutbuy=sympy.cos(x),y.subs(sympy.cos, sympy.cosd)does not work with the above definition ofsympy.cosd(as it's not a sympy function but just a usual lambda function).y.subs(x, pi/180*x)works here, but if the expression in the cos is complicated (like polynomial expression of various parameters) it might not be convenient to search which parameters must be replace with api/180and which must not. - Nihlx,theta,phi, etc. be Symbols representing quantities in radians. Keep a list of these symbols:angles = [x, theta, phi]. Then, at the very end, usey.subs([(angle, angle*pi/180) for angle in angles])to change the meaning of the symbols to degrees. - unutbu