Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #12300

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

From Dennis Lee Bieber <wlfraed@ix.netcom.com>
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
Date 2011-08-27 13:53 -0700
Organization > Bestiaria Support Staff <
References <CADx86fGCVe_r+hXiGpmT8hK7=GsOh82ckHupxAah2rX1bYoURQ@mail.gmail.com> <CADx86fFDnG4+9_E2wu84YQHToN7S1dxBdHFiSwrFuHMEdr-mKw@mail.gmail.com> <CADx86fExq4QSwHH43_254G0iA22xCi4hK6eh_zMX8XzFMtFFZA@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.484.1314478507.27778.python-list@python.org> (permalink)

Show all headers | View raw


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 comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web