Items tagged with interpolation interpolation Tagged Items Feed


I paste below a simple code illustrating what I want to do: interpolate a function from two lists . I wonder it is a very simple task but I the function and the graph I get don't match with the correct ones in the end (both are plotted below).

> y_data:=[0.5266426348e-1, 0.7090942099e-1, 0.9392192453e-1, .1228458380, .1598545751, .2107200296, .3127241088, .4144428927, .5679723063, .6817484378, .7973388763, .9326799232, 1.393259472, 1.493936979, 1.566845149, 1.624353545, 1.670898228, 1.708874880, 1.739919717, 1.765298377, 1.786042765, 1.803007037, 1.816897481, 1.828294327, 1.837670808, 1.845410531, 1.851823072, 1.857157571, 1.861614283, 1.865354162, 1.868506707, 1.871176289, 1.873447229, 1.875387839, 1.877053637, 1.878489894, 1.879733654, 1.880815343, 1.881760039, 1.882588494, 1.883317935, 1.883962726, 1.884534877, 1.885044474, 1.885500010, 1.885908668, 1.886276537, 1.886608800, 1.886909882, 1.887183573, 1.887433127, 1.887661351, 1.887870669, 1.888063180, 1.888240711, 1.888404854, 1.888557000, 1.888698365, 1.888830022, 1.888952911, 1.889067865];

> x_data:=[10, 53/5, 56/5, 59/5, 62/5, 13, 68/5, 68/5, 13, 62/5, 59/5, 56/5, 56/5, 59/5, 62/5, 13, 68/5, 71/5, 74/5, 77/5, 16, 83/5, 86/5, 89/5, 92/5, 19, 98/5, 101/5, 104/5, 107/5, 22, 113/5, 116/5, 119/5, 122/5, 25, 128/5, 131/5, 134/5, 137/5, 28, 143/5, 146/5, 149/5, 152/5, 31, 158/5, 161/5, 164/5, 167/5, 34, 173/5, 176/5, 179/5, 182/5, 37, 188/5, 191/5, 194/5, 197/5, 40];

inverted_pairs:=[seq([y_[i], x_[i]], i = 1 .. nops(y_))]; 

interp := LeastSquares(y_data, x_data, k_, curve = a*k_^3+b*k_^2+c*k_+d);


I've tried different kinds of interpolation methods. In this code I use LeastSquares() function. I'm sure it has a quick solution but I'm really stuck and would appreciate any help/advice.  

Thanks in advance!



PS: I didn't mention in above, but it is really important for me to get the associated function of the curve (e.g. ak_^3+bk_^2+ck_+d). I can get it using LeastSquares() function but with your code (where you use ArrayInterpolation()) the function is not generated in the end. Could you please indicate some way to do that? Thanks!

Hello Maple-Primers!

I am trying to evaluate a system at many different points.  I would like to include an interpolation function in this system, but have thusfar been unsuccessful.

Usually, I solve a system symbolically by using eliminate and unapply:

eq[1] := A = M^3;
eq[2] := C = A*2;
eq[3] := D = N+3;
eq[4] := B = piecewise(A = 0, 0,C);
eq[5] := E = B*D;


{A = 8, B = 16, C = 16, D = 4, E = 64} <--- great!

Now, I want to include an interpolation function in the system of equations.  They look like this (see worksheet for actual interpolation function):

B_interp := (W,T) -> CurveFitting:-ArrayInterpolation([FC_Map_W,FC_Map_T],FC_Map,Array(1 .. 1, 1 .. 1, 1 .. 2, [[[W, T]]]),method=linear);

eq[5] := E = B_interp(N,M);

Error, (in CurveFitting:-ArrayInterpolation) invalid input: coordinates of xvalues must be of type numeric <-- bad!

Anyone have any ideas?  I've tried to use polynomials, but I can't seem to get a fit close enough for my purposes.

I have some data for a model in MapleSim that I would like to use a time look up table with.  I've found that the two options for interpolation are linear and 1st derivative, but the data was intended to be interpretted as piecewise constant.  Is there any way to acheive this option in MapleSim?

I'm trying to interpolate values using spline (data,x,degrees=2).

So I'm setting curvefit:=spline(data,x,degrees=2);


However, I'm trying to solve this over a range of values in matrix M:=1..2000;

I'm sifting through the online documentation, but I can't find a proper way to do this. Ideally, i'd want to store the results as a seperate matrix.

Hi I have been trying to get the inperpolation of some values within a procedure without much success. Maybe someone in mapleprimes might know this already.


Basically what I am trying to do is to generate a matrix of values. The values of the columns 1 to 3 are just some values, but then I want column 4 to be the result of the interpolation of some values.


I got different errors such as: 

Error, (in CurveFitting:-ArrayInterpolation) data must consist of real, floating point values


Anyway the procedure is shown below:


InterProc := proc ()

local i; global A, global variable1, global variable2;

A := Matrix(1 .. 4);

variable1 := [0, 100];

variable2 := [12, 20];


for i from 1 to 10 do

 A(i, 1) := 3+i;

 A(i, 2) := 2*i+A(i, 1);

 A(i, 3) := A(i, 2)-1;

 A(i, 4) := ArrayInterpolation(variable1, variable2, A(i, 1));

end do;

end proc;



I have a 3D data-points of the form x,y,z. What is the easiest way to get the interpolated value z=

I am supposed to adjust the code my teacher gave us for a project. The only problem is I dont know anything about maple or much about what I am supposed to do. I tried copying and pasting the code but I couldn't.

The assignment says to adjust the code to incorporate variable window size. There is a place in the code where it says insert code here and the teacher said it shouldn't need more than like 8 lines of code.


If anybody thinks they they can help I will be more then happy to forward you the email.

We want to fit

f(x) = a_0 + a_1 *x + a_2 * x^2 + ... + a_n * x^n

to the data (x_i,f(x_i)) for i = 0 ... n.


It will give rise to the following system

[ a_i ] = [A]^{-1} * [ f(x_i)].


Here [a_i] = [ a_1 a_2 a_3 ... a_n], 

[A] = [ 1 x_0 x_0^2 ... x_0^n ; 1 x_1 x_1^2 ... x_1^n ; 1 x_2 x_2^2 ... x_2^n ; ... ; 1 x_n x_n^2 ... x_n^n]


[f(x_i)] = [f(x_0) f(x_1) f(x_2) ... f(x_n)].

Good afternoon everbody,

I am trying to make a rational interpolation from the data of a function (values of the function for different points).
I tried to do it with the RationalInterpolation command but it requires too much time. Then I chose to solve the problem with the NonlinearFit command but the result varies a lot if I a change the basic function I want to approach and I always get a warning message: limiting numer of iterations reached.

Hello Everybody!
I am working on an interesting problem right now. Please read it and let me know what you think.

Lets assume there is some function f(v) where v is argument-vector with fixed length. It is known, that the function is a rational type of function with integer coefficients from the vector v.

It is required to find analytic expression for this function.

In other words, we can compute...

I have several functions that cannot be integrated analytically but are to be used (repeatedly!) in further integrations. I have created a table of values of these integrals for a mesh of parameter values.   If I then use the ArrayInterpolation function to compute just one value at one point - it's very inefficient - takes lot's of time...  

   What is the optimal way of defining "InterpolatingFunction"  (in the language of Mathematica)?  Are...


The model that i uploaded (EqQui.msim) has a component with severall output and 4 inputs, but 2 of the inputs (LgKph2o and Lgkpco2) depends on one of the outputs. The 2 interpolation tables transfor the output variable (temperature) in this two inputs. All components works fine independtly (first "model", the one on the top), but if i link the exit of both interpolation tables mapleSim say it cant solve a lot of variables.

In a related question to this answer ( How can we take partial derivatives of the multivariable fitting function (in the example above, the function B(a,b)?
It seems like the package CurveFitting only allows to numerically evaluate the fitted function when we use ArrayInterpolation, but I assume deep in the code there must be an analytic ...

Find the polynomial y=f(x) such that f(-6)=2400,f(-4)=432,f(-3)=120,f(-2)=16,f(-1)=0,f(0)=0,f(1)=-8,f(2)=0

Hi everyone,

I am trying to build a function of dsolve/numeric solution which would not include procedures for defining the value of it.

First, I need to extract solution as a 2-d array, which will contain all evaluated points of solution.

Next, I want to define a function from this set of points (like interpolation).

Say, I have an array or list of numbers (2-d points).

Now comes the main question: is there a way to interpolate some...

1 2 Page 1 of 2