Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

Re: Function interpolation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg45352] Re: Function interpolation
  • From: "Peltio" <peltio at twilight.zone>
  • Date: Fri, 2 Jan 2004 04:23:42 -0500 (EST)
  • References: <bt0uc8$hec$1@smc.vnet.net>
  • Reply-to: "Peltio" <peltioNOSP at Miname.com.invalid>
  • Sender: owner-wri-mathgroup at wolfram.com

"Fernando Ronci" wrote

>I'm new to Mathematica

You could take advantage of the help system.
Type

    ?CommandName

to get information on the syntax of the built-in procedures.
For example,

    ?Table

will help you finding out how to build tables.
Which is not what you need, incidentally.
Bear in mind that the main structure in Mathematica is the expression, with a head
'Head' and arguments 'argn' passed to it inside square brackets.

    Head[arg1,arg2,...]

The head and the arguments can be expressions themselves. For example:

    Sin[x]
    Derivative[f][x]
    Table[Sin[x], {x,0,Pi,Pi/30}]

Mathematica can be seen as an 'evaluator' that parses every expression passed to it
applying user defined and built-in rules until there are no more changes.
There are priorities to be obeyed to, and several methods to force or avoid
the evaluation (you should definitely do a google search for "Mathematica
Tutorial").

A "data structure" that is very widely used in Mathematica is that of List. Lists
can be input as expressions with head List or directly by means of curly
brackets. The can be nested, of course, to create multidimensional objects.

    mylist = List[1,2,3,4]
    mylist = {1,2,3,4}

    mydata = List[ List[0, 0], List[1, 2], List[2, 4] ]
    mydata = {{0, 0}, {1, 2}, {2, 4}}

In your case all you need to do is to input your data as a list, prior to
interpolate it:

    mydata= {{0, 0}, {1, 2}, {2, 4}, {3, 8}, {4, 16}, {5, 32}}
    newfunction = Interpolation[%]
    newfunction[2.3]

Of course if you want you can use Table to build up your list of data:

    mydata= Table[{k, Sign[k] 2^(k-1)}, {k,0,4} ]
    newfunction = Interpolation[%]
    newfunction[2.3]

cheers,
Peltio
--
Invalid address in reply-to. Crafty demunging required to mail me.




  • Prev by Date: why Pi is not recognized as a positive number?
  • Next by Date: Re: How to copy pattern from one expression to another?
  • Previous by thread: Re: Function interpolation
  • Next by thread: RE: Function interpolation