MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: NestWhile and FindRoot[Integrate]

  • To: mathgroup at smc.vnet.net
  • Subject: [mg42421] Re: NestWhile and FindRoot[Integrate]
  • From: "Dinara" <dinara at iastate.edu>
  • Date: Sun, 6 Jul 2003 06:57:03 -0400 (EDT)
  • Organization: Iowa State University
  • References: <be3448$aat$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Well, just ignore q(y) and treat it as q only [it should not matter though,
it just makes a composite functions q(y)y instead of q(y)]
My question is how to make an update of old values with new values. Thanks,
mbekkali at hotmail.com





"Mukhtar Bekkali" <mbekkali at hotmail.com> wrote in message
news:be3448$aat$1 at smc.vnet.net...
> 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.
>
>
>
>




  • Prev by Date: Re: Speed improvements in Mathematica 5 ??
  • Next by Date: problem of Help Browser
  • Previous by thread: Re: NestWhile and FindRoot[Integrate]
  • Next by thread: programming in mathematica