Re: NestWhile and FindRoot[Integrate]
- To: mathgroup at smc.vnet.net
- Subject: [mg42407] Re: NestWhile and FindRoot[Integrate]
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Sat, 5 Jul 2003 03:10:54 -0400 (EDT)
- Organization: Universitaet Leipzig
- References: <be3448$aat$1@smc.vnet.net>
- Reply-to: kuska at informatik.uni-leipzig.de
- Sender: owner-wri-mathgroup at wolfram.com
Hi,
can you post you messages in correct Mathematica syntax ?
because it is not clear, if your problem comes from the
fact the you use algebraic parenthesis for fucntion
calls.
And
D[q(y),y] is interpreted as D[q*y,y] and evaluates to q
and only D[q[y],y] will compute the derivative of the
function q[y]
Regards
Jens
Mukhtar Bekkali wrote:
>
> I have two questions:
>
> I have function f(x,t), where 0<x<1 and trying to find the value of x which
> sets Integrate[f(x,t)g(t),{t,0,1}]=0 for some p.d.f. g(t). So, I programmed
> FindRoot[Integrate[f(x,t)g(t),{t,0,1}]==0,{x,0.5}], however, this head-on
> approach works only for simple functions f(x,t) and g(t). It seems that
> Mathematica is trying to integrate first symbolically and then solve it. Is
> there other way to attach the problem?
>
> Another question relates to loops (totally unrelated to the above problem).
> I am trying to find a maximum of function q(y) using Newton's method (I want
> to do it manually for my own reasons and do not want to use any built-in
> functions). Newton's method essentially substitutes different values of y
> into q(y), but in its special way, and then checks if this is the maximum.
> So my code is as follows (for some specific functions q(y) and parameter z):
>
> y0=0;
> m=D[q(y),y]/D[q(y),{y,2}]
> y1=y0-m/.y->y0;
> NestWhile[{y0=y1,y1=y0-m/.y->y0},{y0,y1},Abs[(q(y)/.y->y1)-(q(y)/.y->y0)]>z]
>
> However, instead of updating y0 and y1 with the old values of y0 and y1
> (i.e. set y0new=y1old and y1new=y0new-m/.y->y0new) it returns the initial
> values of y0 and y1 and that's it.
>
> I thought I can use While instead:
>
> y0=0;
> m=D[q(y),y]/D[q(y),{y,2}]
> y1=y0-m/.y->y0;
> While[Abs[(q(y)/.y->y1)-(q(y)/.y->y0)]>z,{y0=y1,y1=y0-m/.y->y0}]
>
> but this time nothing is returned at all. Essentially, I messed up
> something with updating of values y0 and y1 but cannot figure out what.
>
> Thanks.