MathGroup Archive 2003

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

Search the Archive

Re: Re: Using InterpolateRoot Function in Mathematica

  • To: mathgroup at smc.vnet.net
  • Subject: [mg41226] Re: [mg41212] Re: Using InterpolateRoot Function in Mathematica
  • From: Bobby Treat <drmajorbob at mailblocks.com>
  • Date: Thu, 8 May 2003 09:36:48 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

No, it isn't a typo -- and yes, it's possible.  Evaluate the result and 
see.  Set can be preferable to SetDelayed when it works properly.

"z[L_,x_]=" doesn't work if x or L has a value at this point, or if you 
want any other symbols on the right hand side to take their values at 
evaluation time rather than definition time.  Compare these two 
definitions:

Clear[L, x]
z[L_, x_] := Simplify[
      -(2*x*(L*beta - 3*deltaY))/L^2 - (3*x^2*((-L)*beta +
      2*deltaY))/L^3];
?z

z[L_, x_] = Simplify[
      -(2*x*(L*beta - 3*deltaY))/L^2 - (3*x^2*((-L)*beta +
      2*deltaY))/L^3];
?z

The first definition calls Simplify whenever you use z[L,x], but the 
second calls Simplify only once.  Another approach to Haritha's problem 
would be to define f this way:

f[L_] = Integrate[Sqrt[1 + z[L, x]^2], {x, 0, L}] - L0

That way the symbolic integration occurs only once, whereas

f[L_] := Integrate[Sqrt[1 + z[L, x]^2], {x, 0, L}] - L0

will cause symbolic integration to occur again for each call to f.

In this case, symbolic integration takes quite a while and fails, so 
that doesn't help.  If it did work, it would be better than using 
NIntegrate.

Bobby

-----Original Message-----
From: Dr. Wolfgang Hintze <weh at snafu.de>
To: mathgroup at smc.vnet.net
Subject: [mg41226] [mg41212] Re: Using InterpolateRoot Function in Mathematica

Bobby,

Just a question: is the line
z[L_,x_]=-(2*x*(...
a typing error, i.e. shouldn't it read
z[L_,x_]:=-(2*x*(...?
Or is a definition like that possible, and if so, what does it mean?

Regards,
Wolfgang



Bobby Treat wrote:

> Needs["NumericalMath`InterpolateRoot`"]
> 
z[L_,x_]=-(2*x*(L*beta-3*deltaY))/L^2-(3*x^2*((-L)*beta+2*deltaY))/L^3;
> deltaY=0.000254;L0=.013;alpha=5;
> beta=Tan[alpha*(Pi/180)];
> f[L_?NumericQ]:=NIntegrate[Sqrt[1+z[L,x]^2],{x,0,L}]-L0
> InterpolateRoot[f[L],{L,.01,.02}]
>
> {L -> 0.012992620790646777121996501}
>
> NIntegrate and NumericQ help avoid the messy symbolic integral.  
Making
> z an explicit function isn't essential, but I gave up getting past
> NIntegrate's HoldAll attribute without it.
>
> Bobby
>
> -----Original Message-----
> From: Haritha Yalamanchili <haritha12 at attbi.com>
To: mathgroup at smc.vnet.net
> mathgroup at smc.vnet.net
> Subject: [mg41226] [mg41212] Re:  Using InterpolateRoot Function in Mathematica
>
> Hi Bobby,
>
> Thank you for the response. I did not enter the exact mathematica
> format, I
> only used the symbolic notation to explain the problem (sorry if this
> caused
> any confusion). Attached is the mathematica file I was using to solve
> for
> the arclength.
>
> deltay, beta and L0 are constants. Also L0 can be used as an initial
> guess
> for the root (L).
>
> I was able to solve this problem in Mathcad, on one of my friends
> computer,
> but I would prefer to solve in Mathematica , as I am more comfortable
> using
> Mathamatica.
>
> Any help that you could provide is greatly appreciated.
>
> Thank You
> Prasad
> ----- Original Message -----
> From: "Bobby Treat" <drmajorbob+MathGroup3528 at mailblocks.com>
To: mathgroup at smc.vnet.net
> Subject: [mg41226] [mg41212] Re:  Using InterpolateRoot Function in Mathematica
>
>
>
>>First, why write
>>
>>f(L) = Integrate[sqrt(1+z^2) dx] - L0 (Integration limits are from 0
>>
> to
>
>>L)
>>
>>if you mean
>>
>>f[L_]:= Integrate[sqrt(1+z^2),{z,0,L}] - L0
>>
>>??
>>
>>This leaves me wondering if you entered that, or something else.  The
>>possible errors you MIGHT have made are endless, so it would really
>>help if you just showed us the statement you entered.
>>
>>Secondly, what is L0?  Another unknown?  A parameter?
>>
>>Bobby
>>
>>-----Original Message-----
>>From: Haritha Yalamanchili <haritha12 at attbi.com>
To: mathgroup at smc.vnet.net
>>To: mathgroup at smc.vnet.net
>>Sent: Sun, 4 May 2003 03:56:52 -0400 (EDT)
>>Subject: [mg41226] [mg41212]  Using InterpolateRoot Function in Mathematica
>>
>>Hi,
>>
>>I am trying to use Mathematica to find a value of "L" that satisfies
>>
> the
>
>>equation
>>
>>Integrate[sqrt(1+z^2) dx] - L0 = 0 (Integration limits are from 0 to
>>
> L)
>
>>where,
>>
>>z= -2 x(L C1 - 3 C2)/L^2 - 3 x^2(-L C1 + 2 C2)/L^3
>>
>>In order to find the value of L that satisfies the above equation, I
>>have
>>setup the problem in Mathematica as shown below. Can some one help to
>>verify
>>if the problem is setup properly of if Mathematica is capable of
>>finding a
>>root for such functions.
>>
>>******
>>f(L) = Integrate[sqrt(1+z^2) dx] - L0 (Integration limits are from 0
>>
> to
>
>>L)
>>
>>InterpolateRoot[ f(L),{L,0,L0} ]
>>*******
>>(L0=13, C1=0.12, C2=0.25)
>>
>>Value of L is close to L0 and hence, L0 can be used as the initial
>>
> guess
>
>>value.
>>
>>Thank You and Best Regards
>>Prasad
>>
> 


  • Prev by Date: pde's and method of lines
  • Next by Date: Re: Re: Re: How change $AddOnsDirectory
  • Previous by thread: Re: Using InterpolateRoot Function in Mathematica
  • Next by thread: Re: Re: Using InterpolateRoot Function in Mathematica