Search code examples
pythonmathequationexp

python equation calculation with exp() function


Here is the equation I'm tryin' to solve:

original

the correct answer most be 0.347 and this is what I got:

from math import *

exp(((-4.4 + 0.6*(0.6/1.2))*tan(25)) + ((3.07*sin(25))*(log(2*4.29))/(1+sin(25))))

output:

0.6318

I tried to use radians : tan(radians(25)) I keep getting wrong results


Solution

  • 0.347 (ignoring the rounding error) is correct if you use the base 10 logarithm and your arguments are in degrees for the trigonometry functions.
    0.6318 is correct for natural logarithm and radians.

    >>> from math import exp, log, sin, tan, radians
    >>> exp(((-4.4 + 0.6*(0.6/1.2))*tan(radians(25))) + ((3.07*sin(radians(25)))*(log(2*4.29, 10))/(1+sin(radians(25)))))
    0.34627767629783546