Items tagged with interpolation interpolation Tagged Items Feed

I have an arrays of data. One for x values, and one for y values. How can I obtain a numerical integration of y for a range of x values?

I have tried defining a function of X using ArrayInterpolation(x,y,X) and then calling evalf(Int(f,xmin..xmax)) but that gives an error message. (I don't seem to be able to paste into this window) The error message says

"Error, invalid input: evalf expects its 2nd argument, n, to be of type posint, but received numeric."

I thought I was using a form of the equation right from the help system.

I also tried the 2D version of integration, but it returns the difference of my limits times my function name.

I aslo tried AdaptiveQuadrature, but I can't get that to work either.

-Mike McDermott

Newbie Maple user

 

 

Hi,

I have a small problem. I want to findout area under a curve. I got the plot from solving a partial differential equation. I want to find out area under the curve with out using interpolation. Are there any methods to find this.

 

here i enclose the method i have done.

Es := 0.117108e12:
Ef := 0.78125e11:
l := 0.150e-6:
s := 0.500000e-3:
f := 0.5898334197e-6:
o := 0.9e-5:
d := 0.10e-17:
cb := 0.1e7/(19.9):
c := l*f/(d*cb):

PDE := diff(u(x, t), t)-(diff(u(x, t), x, x)) = 0:
            
with(plots):
with(plottools):
ys := -0.4245333333e-1:
IBC1 := {u(x, 0) = 0, (D[1](u))(0, t) = 0, (D[1](u))(1, t) = c}:
S1 := pdsolve(PDE, IBC1, numeric, time = t, timestep = 0.1e-2);

p2 := S1:-plot(t = .2525);

p3 := getdata(p2);

p3[3]:
co:=CurveFitting[PolynomialInterpolation](p3[3], x):
Area := int(co, x = x[1] .. x[2]):

So this is the procedure i used to find out, but can there be any other procedure to findout area directly from hte solution of PDE.

Thanks.



 

I have data file with 6 columns:

X Y Z B1 B2 B3

i.e. 3 coordinates (with some step) and values of B-functions at that 3D point. How to make interpolation of these B-functions to have them in arbitrary (x,y,z) point?

Then I need to solve diff equations like this:

x''(s)+f(...)=0

f(...) depends on x,y,z,x',y',z' and B1,B2,B3. How to write this dsolve(...) construction when we have interpolations inside?

Thanks.

Dear,

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;
elimsol:=eliminate(convert(eq,list),[A,B,C,D,E])[1];

unappsol:=unapply(elimsol,[N,M]);

unappsol(1,2);
{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.

Maple_2D_Interpolate_FC.mw

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);

fsolve(curvefit=4,x);

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];

with(CurveFitting);

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;

 

InterProc();

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]

and 

[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...

Hi,

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.

1 2 Page 1 of 2