Re: Linear Interpolation problems

*To*: mathgroup at smc.vnet.net*Subject*: [mg102377] Re: Linear Interpolation problems*From*: Bill Rowe <readnews at sbcglobal.net>*Date*: Fri, 7 Aug 2009 05:30:41 -0400 (EDT)

On 8/6/09 at 6:33 AM, leekosal at yahoo.com (kosal lee) wrote: >First, suppose I have two real values >year earnings >x = 3 f(x) = 20 >x= 10 f(x) = 50 >I want to have the interpolated values of f(4), f(5), to f(9) which >is between actual values of f(3) and f(10). How can I do that with >Mathematica? The Mathematica functions most specific to this problem are Interpolation, Map and Range. They can be used to do what you want as follows: In[6]:= f = Interpolation[{{3, 20}, {10, 50}}, InterpolationOrder -> 1]; f /@ Range[3, 10] Out[7]= {20, 170/7, 200/7, 230/7, 260/7, 290/7, 320/7, 50} The first line creates the linear interpolation function. The second line maps that function to the desired range of values. Note, I've used the shorthand notation /@ for Map. >Second, suppose I have an excel spreadsheet having those above >values for multiples firms as of the following >firm f(3) f(10) >A 20 50 >B 30 55 >C 60 25 This can be done as follows: In[8]:= g = Interpolation[{{3, First@#}, {10, Last@#}}, InterpolationOrder -> 1] & /@ {{20, 50}, {30, 55}, {60, 25}}; data = Table[g[[n]] /@ Range[3, 10], {n, 3}] Out[9]= {{20, 170/7, 200/7, 230/7, 260/7, 290/7, 320/7, 50}, {30, 235/ 7, 260/7, 285/7, 310/7, 335/7, 360/7, 55}, {60, 55, 50, 45, 40, 35, 30, 25}} >I want to have the values of f(4) till f(9) as above and are stored >in excel spreadsheet as of the following: >firm f(3) f(4) f(5) ... (f9) f(10) >A 20 50 >B 30 55 >C 60 25 Writing the information to Excel can be done by Export["filename.xls", data//N, "XLS"] Here, I've converted the exact results returned by Mathematica to machine precision numbers since I don't think Export converts exact results to something Excel understands as a number. This may not be needed. But since I have little use for Excel, I've not taken the time to determine the need for this conversion.

**Follow-Ups**:**Re: Re: Linear Interpolation problems***From:*kosal lee <leekosal@yahoo.com>

**On solving equations for variables included in functions R^n to R**

**Re: error with Sum and Infinity**

**Re: Linear Interpolation problems**

**Re: Re: Linear Interpolation problems**