Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #12300 > unrolled thread
| Started by | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| First post | 2011-08-27 13:53 -0700 |
| Last post | 2011-08-27 13:53 -0700 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: 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 Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2011-08-27 13:53 -0700
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| Date | 2011-08-27 13:53 -0700 |
| Subject | Re: 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 |
| Message-ID | <mailman.484.1314478507.27778.python-list@python.org> |
On Sun, 28 Aug 2011 03:24:33 +0800, Xiong Deng <dbigbear@gmail.com>
declaimed the following in gmane.comp.python.general:
> >>>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)
>
<snip>
> 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??? If there are any other methods
> without Sympy, it is still OK.
>
Trying a WAG... Perhaps you need to defer execution of said
functions within the equation... Maybe with lambda?
(lambda x=x: log(x))(x)
???
I don't have sympy installed, and the online example of .solve()
doesn't show any examples with nested functions (that is, where 'x' is
an argument to a function that is itself an argument to a function in
the equation).
Or perhaps you need to define log() as a symbolic function itself,
and include it in the list of variables?
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
Back to top | Article view | comp.lang.python
csiph-web