Re: [sage-support] Interpolation in Sage

2015-07-22 Thread Michael Orlitzky
On 07/22/2015 04:04 PM, Santanu Sarkar wrote:
> Hello,
>I want to find a polynomial f(x_1,x_2,x_3,x_4) explicitly
> by interpolation. I know that the degree of f is 2. I have enough data
> points.  How can I do this in Sage?
> 

I have some code to do this here:

http://michael.orlitzky.com/git/?p=sage.d.git;a=blob;f=mjo/interpolation.py

It has sage-style tests and examples. Here's a simple example
interpolating something that looks like f(x) = x^3:

sage: xs = [-2,-1,0,1,2]
sage: ys = [-8,-1,0,1,8]
sage: f = lagrange_polynomial(x, xs, ys)
sage: f
1/3*(x + 2)*(x + 1)*(x - 1)*x - 1/6*(x + 2)*(x + 1)*(x - 2)*x + 1/6*(x +
2)*(x - 1)*(x - 2)*x - 1/3*(x + 1)*(x - 1)*(x - 2)*x
sage: f(x = -2)
-8
sage: f(x = -1)
-1
sage: f(x = 0)
0
sage: f(x = 1)
1
sage: f(x = 2)
8

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


Re: [sage-support] Interpolation in Sage

2015-07-22 Thread Jorge Garcia
Take a look at example 75) https://sagecell.sagemath.org/?q=zeplgw
HTH,
AJG

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Interpolation in Sage

2015-07-22 Thread Santanu Sarkar
Hello,
   I want to find a polynomial f(x_1,x_2,x_3,x_4) explicitly
by interpolation. I know that the degree of f is 2. I have enough data
points.  How can I do this in Sage?

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.