Items tagged with interpolation interpolation Tagged Items Feed

I came across this interesting image restoration in the Mathematica community http://community.wolfram.com/groups/-/m/t/873396 and wondered how this could be applied in Maple.

 

Hi

Please find the attached file

The command PolynomialInterpolation doesn't work, I will be appreciate if you can help me

Thanks

 

Question.mw

 

``

restart

``

``

(1)

``

interface(displayprecision = 4)

-1

(2)

(3)

NULL

``

Vert_Coef := Matrix(10, 5, {(1, 1) = 0.332e-1, (1, 2) = 0.187e-1, (1, 3) = 0.104e-1, (1, 4) = 0.52e-2, (1, 5) = 0.21e-2, (2, 1) = 0.509e-1, (2, 2) = 0.301e-1, (2, 3) = 0.166e-1, (2, 4) = 0.83e-2, (2, 5) = 0.31e-2, (3, 1) = 0.571e-1, (3, 2) = 0.364e-1, (3, 3) = 0.218e-1, (3, 4) = 0.104e-1, (3, 5) = 0.42e-2, (4, 1) = 0.582e-1, (4, 2) = 0.405e-1, (4, 3) = 0.260e-1, (4, 4) = 0.125e-1, (4, 5) = 0.42e-2, (5, 1) = 0.582e-1, (5, 2) = 0.416e-1, (5, 3) = 0.270e-1, (5, 4) = 0.135e-1, (5, 5) = 0.52e-2, (6, 1) = 0.582e-1, (6, 2) = 0.416e-1, (6, 3) = 0.281e-1, (6, 4) = 0.145e-1, (6, 5) = 0.52e-2, (7, 1) = 0.582e-1, (7, 2) = 0.416e-1, (7, 3) = 0.291e-1, (7, 4) = 0.166e-1, (7, 5) = 0.62e-2, (8, 1) = 0.582e-1, (8, 2) = 0.416e-1, (8, 3) = 0.301e-1, (8, 4) = 0.177e-1, (8, 5) = 0.62e-2, (9, 1) = 0.582e-1, (9, 2) = 0.416e-1, (9, 3) = 0.301e-1, (9, 4) = 0.187e-1, (9, 5) = 0.73e-2, (10, 1) = 0.582e-1, (10, 2) = 0.416e-1, (10, 3) = 0.301e-1, (10, 4) = 0.197e-1, (10, 5) = 0.83e-2})

Matrix(10, 5, {(1, 1) = 0.332e-1, (1, 2) = 0.187e-1, (1, 3) = 0.104e-1, (1, 4) = 0.52e-2, (1, 5) = 0.21e-2, (2, 1) = 0.509e-1, (2, 2) = 0.301e-1, (2, 3) = 0.166e-1, (2, 4) = 0.83e-2, (2, 5) = 0.31e-2, (3, 1) = 0.571e-1, (3, 2) = 0.364e-1, (3, 3) = 0.218e-1, (3, 4) = 0.104e-1, (3, 5) = 0.42e-2, (4, 1) = 0.582e-1, (4, 2) = 0.405e-1, (4, 3) = 0.260e-1, (4, 4) = 0.125e-1, (4, 5) = 0.42e-2, (5, 1) = 0.582e-1, (5, 2) = 0.416e-1, (5, 3) = 0.270e-1, (5, 4) = 0.135e-1, (5, 5) = 0.52e-2, (6, 1) = 0.582e-1, (6, 2) = 0.416e-1, (6, 3) = 0.281e-1, (6, 4) = 0.145e-1, (6, 5) = 0.52e-2, (7, 1) = 0.582e-1, (7, 2) = 0.416e-1, (7, 3) = 0.291e-1, (7, 4) = 0.166e-1, (7, 5) = 0.62e-2, (8, 1) = 0.582e-1, (8, 2) = 0.416e-1, (8, 3) = 0.301e-1, (8, 4) = 0.177e-1, (8, 5) = 0.62e-2, (9, 1) = 0.582e-1, (9, 2) = 0.416e-1, (9, 3) = 0.301e-1, (9, 4) = 0.187e-1, (9, 5) = 0.73e-2, (10, 1) = 0.582e-1, (10, 2) = 0.416e-1, (10, 3) = 0.301e-1, (10, 4) = 0.197e-1, (10, 5) = 0.83e-2})

(4)

``

``

whattype(Vert_Coef)

Matrix

(5)

``

NULL

``

``

``

``

SR := Vector([10.8696, 21.7391, 32.6087, 43.4783, 46.7391, 54.3478, 65.2174, 76.0870, 86.9565, 100.0000], datatype = float)

Vector(10, {(1) = 10.8696, (2) = 21.7391, (3) = 32.6087, (4) = 43.4783, (5) = 46.7391, (6) = 54.3478, (7) = 65.2174, (8) = 76.0870, (9) = 86.9565, (10) = 100.0000})

(6)

E_G := Vector([250, 500, 1000, 2500, 10000], datatype = float)

Vector(5, {(1) = 250.0000, (2) = 500.0000, (3) = 1000.0000, (4) = 2500.0000, (5) = 10000.0000})

(7)

``

``NULL

NULL

``

NULL

``

B_interp := proc (SR, E_G) options operator, arrow; CurveFitting:-ArrayInterpolation([SR, E_G], Vert_Coef, Array(1 .. 1, 1 .. 1, 1 .. 2, [[[SR, E_G]]]), method = linear) end proc

proc (SR, E_G) options operator, arrow; CurveFitting:-ArrayInterpolation([SR, E_G], Vert_Coef, Array(1 .. 1, 1 .. 1, 1 .. 2, [[[SR, E_G]]]), method = linear) end proc

(8)

``

``

f[18*_1] := B_interp(25.0, 1500.0)

Error, (in CurveFitting:-ArrayInterpolation) invalid input: dimensions of independent data do not match the dimensions of dependent data

 

 

Download Matrix_Interpolation.mw

Hello Mapleprime Community,

Would you be kind to help me with the attached Maple worksheet. My goal is to do a 2D interpolation given the value of SR (slenderness ratio) and E_G (Young's modulus / Shear modulus ratio) in the Matrix table Vert_Coeff with header as vector E_G and the other as vector SR. I’m confused as to how to do the interpolation. Please help.

 

Regards,

 

Moses

Hello,

 

I am trying to find the interpolation of a 3D function.

I have the vector x, the vector y and a matrix M at my disposition.
I know how to do the pointplot3d , but I can not find the function: f(x,y) 

any suggestion?

 

Thank you for help

Hi. Is there a maple function which can interpolate values from a simple table:

given (x,y) compute z value

eg z(0.5,0.5)=1.5

x:=[0,1,2];y:=[0,1,2]

array:=[0,2,4;1,3,5;2,4,6] #probably the wrong input, but you get the idea

ArrayInterpolation?

there is a method in vba:

http://www.tushar-mehta.com/excel/newsgroups/interpolation/#Two_dimensional_interpolation_

how to do optimization for two equations in terms of two variables

 

LPSolve({eq1}, {eq2}, assume = {nonnegative});

 

eq1 is a rational function and eq2 is a very large rational function

after run , it return error, objective function must be specified as a linear polynomial or vector

 

da := [LengthSplit(Flatten([[1,m],[2,m2],[seq([i+1,close3[i][1]], i=2..4)]]),2)];
f := PolynomialInterpolation(da, z):
solution := solve(f=-z, z, explicit);
zz := [x1,x2,x3,x4];
sigma := symMonomial(zz); #sigma := [x1+x2+x3+x4, x1*x2+x1*x3+x1*x4+x2*x3+x2*x4+x3*x4, x1*x2*x3+x1*x2*x4+x1*x3*x4+x2*x3*x4, x1*x2*x3*x4]
sys1 := subs([x1=solution[1],x2=solution[2],x3=solution[3],x4=solution[4]], sigma[1]):
sys2 := subs([x1=solution[1],x2=solution[2],x3=solution[3],x4=solution[4]], sigma[2]):
sys3 := subs([x1=solution[1],x2=solution[2],x3=solution[3],x4=solution[4]], sigma[3]):
sys4 := subs([x1=solution[1],x2=solution[2],x3=solution[3],x4=solution[4]], sigma[4]):
da := [seq([i,close3[i][1]], i=1..5)];

with(Optimization):
LPSolve(sys1, {sys2}, assume = {nonnegative});

 

how to further remove _Z with explicit in two variables case?

da := [[1,m],[2,m2],[3,1],[4,2],[5,3],[6,4]];
f := PolynomialInterpolation(da, z):
solution := solve(f=-z, z, explicit);

 

Hi !

I am trying to solve a pde with initial/boundary conditions, in the numeric mode. It works very well when I provide 3 numerical conditions : 1 initial condition (uniform distribution at first), and two boundary conditions.

Now I want to switch the initial condition to a function of r. It's a polynome I obtained after interpolation of another result. I tested it and the function interp20(r) works. But the pdsolve doesn't seem to evaluate the function, when it comes to start the procedure and pdsolve doesn't return a module as it should, although it doesn't send any message error.

You can see the code following, with the error messages I get.

 

Is it strictly impossible to use a function as an initial condition ?
Is it just a problem I could solve by converting the function or its result to something else ?
Is float the right type of input ? For example, if I write a:=283.15, is it a float ?
Have you already had similar problems ? How did you solve them ? Where could I find working code examples on this ?
Could I solve this problem with non-uniform initial condition with another Maple function ?

Then you very much for your help !

 

 

I have some X-Y data, and I would like to calculate a definate integral of the data. In this case x_data and y_data are vectors.

I tried this method.

y:=x->ArrayInterpolation(x_data,y_data,x)

But when I try to calculate an integral like this, I get an error.

int(y, x0..x1)

Error, (in int) operator y cannot be evaluated at one variable.

What is this error trying to tell me? I have tested by function y for values x1 and x2. My data is smooth and includes x1 and x2. I have no reason to believe that the function cannot be evaluated for any value of x. 

Is there another (better) way to do what I want? This is a part of a large worksheet that reads data from an excel file, and I don't know how to reduce the worksheet for only this problem.

Thanks.

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?

1 2 3 Page 1 of 3