[Date Index]
[Thread Index]
[Author Index]
Re: FindRoot question
*To*: mathgroup at smc.vnet.net
*Subject*: [mg5475] Re: [mg5424] FindRoot question
*From*: Sherman Reed <Sherman.Reed at worldnet.att.net>
*Date*: Wed, 11 Dec 1996 03:15:56 -0500
*Sender*: owner-wri-mathgroup at wolfram.com
At 05:25 AM 12/7/96 +0000, you wrote:
>
>I have a question concerning efficient use of FindRoot.
>
>Consider the following code:
>
>h=.5
>
>k=1
>
>f=.2
>
>j2[t_,b_]:= -(2*h*k - 4*b*h*k + b*h^2*k + 2*b*h*k^2 - 4*f*t + 4*b*f*t -
2*b*f*k*t + b*h*k*t)/(2*(2 - 2*b + b*k)*(-h + t))
>
>j3[t_,b_]:=N[Which [j2[t,b]<0,0,j2[t,b]>1,1,True,j2[t,b]]]
>
>j4[z_]:=N[Integrate[b j3[z,b],{b,0,1}]]
>
>This works fine. j2 defines a function, j3 truncates it at 0 and 1,
>and j4 integrates j3 with respect to one of its arguments. Nothing
>complicated here.
>
>If I do:
>
>Plot [z j4[z]-f,{z,0,1}]
>
>I get a nice upward sloping graph that clearly crosses the horizontal
>axis at about z=.4. So, z=.4 is approximately a real root.
>
>Next, I try:
>
>FindRoot [z j4[z]-f,{z,.4}]
>
>But (and this is the problem) mathematica just sits there. I presume
>it is calculating, but I have been waiting for over 15 minutes and it
>is still grinding away, this despite the fact that my guess at the
>root (.4) is alomost correct. Am I doing something wrong? Is there
>an easier way to get mathematica to calculate roots?
>
>Thanks.
>
>Michael
>
>
I think you did just fine, but not quite in the right format.
I first tried
FindRoot [z j4[z]-f==0,{z,.4}] and I got an error statement in two or three
seconds. FindRoot asked for another value for the initial guess, so I gave
the following:
FindRoot [z j4[z]-f==0,{z,.4,.39}] and it produced the answer.\
sherman reed
Prev by Date:
**Re: Mathematica etc.**
Next by Date:
**Re: Solving a numerical integration**
Previous by thread:
**FindRoot question**
Next by thread:
**Re: FindRoot question**
| |