For Programmers: Free Programming Magazines  


Home > Archive > Mathematica > August 2006 > Why polynomial Can't output as single Number?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Why polynomial Can't output as single Number?
William

2006-08-26, 4:02 am

data={7,2,3,25,1,10};
f=InterpolatingPolynomial[data,x];
f/.x->5;

Result as attachment picture.

why can't get a simply number?

thanks

Please see picture:
http://lh3.google.com/sunose/RO6YrI.../polynomial.JPG

thanks

Jean-Marc Gulliet

2006-08-26, 4:03 am

William wrote:
> data={7,2,3,25,1,10};
> f=InterpolatingPolynomial[data,x];
> f/.x->5;
>
> Result as attachment picture.
>
> why can't get a simply number?
>
> thanks
>
> Please see picture:
> http://lh3.google.com/sunose/RO6YrI.../polynomial.JPG
>
> thanks
>


Works fine here. Try with a fresh kernel without loading any packages to
see what happens.

In[1]:=
data = {7, 2, 3, 25, 1, 10};
f = InterpolatingPolynomial[data, x];
f /. x -> 5

Out[3]=
1

In[4]:=
N[f /. x -> 5]

Out[4]=
1.

In[5]:=
N[f /. x -> 5, 2]

Out[5]=
1.0

In[6]:=
dd = N[f /. x -> 5, 2]

Out[6]=
1.0

In[7]:=
Head[dd]

Out[7]=
Real

In[8]:=
$Version

Out[8]=
5.2 for Microsoft Windows (June 20, 2005)

HTH,
Jean-Marc

Chris Chiasson

2006-08-26, 4:03 am

that produces the number 1 on my system
maybe you need to Clear some of the variables?



On 8/26/06, William <sunose@gmail.com> wrote:
> data={7,2,3,25,1,10};
> f=InterpolatingPolynomial[data,x];
> f/.x->5;
>
> Result as attachment picture.
>
> why can't get a simply number?
>
> thanks
>
> Please see picture:
> http://lh3.google.com/sunose/RO6YrI.../polynomial.JPG
>
> thanks
>
>



--
http://chris.chiasson.name/

William Wang

2006-08-27, 4:06 am

yes.
Bob give me a answer:

Clear[f];
f[x_]=InterpolatingPolynomial[data,x];
f[5]

get correct result.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com