Home > Mobile >  Having trouble inverting a simple math equation using logarithms in Python
Having trouble inverting a simple math equation using logarithms in Python

Time:12-10

After trying to reverse a very simple math formula for the past day, I've given up after bumping my head against scipy.special.lambertw -- which might not even be the correct place to be looking.

I have the following equation:

import numpy

# The following == 70.03
np.sqrt(np.log(742) * 742)

I'm trying to invert that equation -- where inputing 70.03 would equal 742.

Here was my current attempt after playing around with an algebra solver and Wolfram Alpha:

from scipy.special import lambertw

np.power(np.power(np.e, lambertw(70.03)), 2)

This obviously produces an incorrect answer — but since algebra was so long ago, I'm basically lost as to how to produce a function that coverts 70.03 back into 742.

Thanks for any help!

CodePudding user response:

From WolframAlpha I get

from scipy.special import lambertw

f = lambda x: x ** 2 / lambertw(x ** 2)

as the inverse.

indeed

f(70.03) gives (742.008379366021 0j)

but i dont have the mathematics to find what wolframalpha found, i hope you understand why f above is the inverse really

  • Related