MathGroup Archive 2007

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

Search the Archive

About Mathematica Evaluation...

  • To: mathgroup at smc.vnet.net
  • Subject: [mg73841] About Mathematica Evaluation...
  • From: Juha Pahkala <jpahka at welho.com>
  • Date: Fri, 2 Mar 2007 06:20:45 -0500 (EST)

Hi,

In the Mathematica code below, I'm trying to use a Cubic Spline 
function, using FindRoot to search the x point related to the spline 
parameter. There's two slightly different implementations, one of which 
produces correct and the other obviously incorrect result. I don't 
understand why the latter method (ie. not defining an intermediate 
function) does not work. Could someone kindly elaborate?

Thanks in advance,

Juhis


In[19]:=
<<NumericalMath`SplineFit`

In[21]:=
pts={{1,37.8505},{2,60.6265},{3,93.377},{5,159.351},{7,207.2515}};

In[22]:=
sr=SplineFit[pts, Cubic]

Out[22]=
SplineFunction[Cubic, {0.,4.}, <>]

In[23]:=
tmp[q_?NumericQ]:=sr[q][[1]];

In[24]:=
FindRoot[tmp[y]==6,{y,0,4}]

Out[24]=
{y->3.4865}

In[25]:=
FindRoot[sr[y][[1]]==6,{y,0,4}]

Out[25]=
{y->6.}



  • Prev by Date: Re: Hold and Equal
  • Next by Date: Number of digits
  • Previous by thread: Re: Integrals involving square roots
  • Next by thread: Number of digits