[SciPy-User] How can I solve a equation like solve a function containint expressions like sqrt(log(x) - 1) = 2 and exp((log(x) - 1.5)**2 - 3) = 5
Xiong Deng
dbigbear@gmail....
Sat Aug 27 14:16:16 CDT 2011
HI,
Hi, I am trying to solve an equation containing both exp, log, erfc, and
they may be embedded into each other....But sympy cannot handle this, as
shown below:
>>> from sympy import solve, exp, log, pi
>>>from sympy.mpmath import *
>>>from sympy import Symbol
>>>x=Symbol('x')
>>>sigma = 4
>>>mu = 1.5
>>>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)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File
"/home/work/local/python-2.7.1/lib/python2.7/site-packages/sympy/mpmath/functions/functions.py",
line 287, in log
return ctx.ln(x)
File
"/home/work/local/python-2.7.1/lib/python2.7/site-packages/sympy/mpmath/ctx_mp_python.py",
line 984, in f
x = ctx.convert(x)
File
"/home/work/local/python-2.7.1/lib/python2.7/site-packages/sympy/mpmath/ctx_mp_python.py",
line 662, in convert
return ctx._convert_fallback(x, strings)
File
"/home/work/local/python-2.7.1/lib/python2.7/site-packages/sympy/mpmath/ctx_mp.py",
line 556, in _convert_fallback
raise TypeError("cannot create mpf from " + repr(x))
TypeError: cannot create mpf from x
But sqrt, log, exp, itself is OK, as shown as below:
>>> solve((1.0 / sqrt(2 * pi) * x * sigma) - 1, x)
[0.626657068657750]
SO, How can I solve an equation containint expressions like sqrt(log(x) -
1)=0 or exp((log(x) - mu)**2 - 3) = 0???
Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20110828/c788a1fc/attachment.html
More information about the SciPy-User
mailing list