[SciPy-User] How can I solve a equation like sqrt(log(x)*erfc(exp(log(x)+1)) - 1) = 2 and exp((log(x) - 1.5)**2 - 3) = 5
Robert Kern
robert.kern@gmail....
Sun Aug 28 02:36:06 CDT 2011
On Sun, Aug 28, 2011 at 01:18, Johnny <dbigbear@gmail.com> wrote:
> Hi, I am trying to solve the follow equation:
>
> solve(x * ((1.0 / sqrt(2 * pi) * x * sigma) * exp(-0.5 * (log(x) -
> mu)**2 / sigma**2)) + 0.5 * erfc((mu - log(x)) / (sigma * sqrt(2))) -
> 1, x)
>
> I am not sure Scipy can do it and how it can do it ?
[~]
|18> from numpy import sqrt, log, exp
[~]
|19> from scipy.special import erfc
[~]
|20> def f(x, mu=1.0, sigma=0.1):
...> return x * ((1.0 / sqrt(2 * pi) * x * sigma) * exp(-0.5 * (log(x) -
...> mu)**2 / sigma**2)) + 0.5 * erfc((mu - log(x)) / (sigma *
sqrt(2))) - 1.0
...>
[~]
|21> from scipy.optimize import fsolve
[~]
|22> fsolve(f, 3.0)
array([ 2.88207063])
[~]
|23> f(_)
array([ 4.44089210e-16])
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
More information about the SciPy-User
mailing list