Items tagged with spline

I need to solve an ode of the type ay''+by'+cy=f(x) using cubic b spline.

can any one help me with the code or algorithm. Thanks


I'm solving a 2D grid with some finite-diference methods. The result is a surface, i.e f(x,y) = z. Where X and Y and points on a grid. 


I then need to integrate over this grid, i.e

int(f(x,y),[x=0..10, y=0..10]) 

I have tried interpolating the grid. I've used CurveFitting:-ArrayInterpolation() to interpolate points in this 2D space and then integrate over them. 

I'm using a 30x30 grid, but this interpolation scheme takes far too long. The function generated from the ArrayInterpolation creates an interpolation every time a point is evaluated, which I assume is why the integral is very computationally expensive. 

I would like to create a piecewise analytic function from the 2-D grid, perhaps using CurveFitting:-Spline(), however from my understanding this only works for 1D objects? 

Is there any better solution for integrating a 2D numeric grid?

Thanks in advance


I would like to understand this code which has been discussed in the forum a moment ago.

Here the Maple code :

Does somebody know the theoric developpements to this code ?

May you help me to add comments so as to facilitate the link with the theory ? One line in front of each procedure should be enough for me to understand. For the moment, I didn't manage to match it with the theory.

When I would understand this code, I would like in a second step compare the result with Catmull-Rom splines.

Thanks a lot for your help.

 @acer : I think this subject may interest you



I try to use a Catmull-Rom spline which has to match on several points.

I use a code extracted from the book "Geometry and curves with maple".

Here you can find an extract which is visible from google book :

I have slightly modified the initial procedure crom_2d. I didn't find the error in my procedure. May you help me to find the blocking point of my procedure ?

Here I attached my code:

Thank you for your help.


This question is related to and , however I have not been able to apply the solutions given there to my problem.

I have a set of points given by

and certain function value points given by

where e1 is the function I am approximating.


I come up with my piecewise function.

When I do diff(e4,x), however, the points at the nodes show "float(undefined) x=0.2..."(the node).

As it turns out, the value of the derivative on the left of the node is not equal to that of the right side by a factor of 10^(-7), in other words, numerically unimportant but high enough for maple to realise it is not the same number. How could I tell Maple that I am happy choosing, for example, the value given by the function on right side of the node?

I welcome any suggestions.

Many thanks in advance.

Hello everyone, 

I have a question regarding my Spline interpolations. I am not an expert on the theory there, but the maple help tells me that the first derivative of an 3rd degree spline interpolation should exist at the knots. But a derivation returns "undefined" at some of the knots instead. Here is my example:

x(t):=Spline([[0, 0], [1, 1], [2, 2], [3, 2.2], [4, 1.8]],t,degree=3);


x(t):=piecewise(t < 1, .953571428571429*t+0.464285714285714e-1*t^3, t < 2, -0.9286e-1+1.09285714285714*t+.139285714285714*(t-1)^2-.232142857142857*(t-1)^3, t < 3, .65000+.675000000000000*t-.557142857142857*(t-2)^2+0.821428571428571e-1*(t-2)^3, 2.77857-.192857142857143*t-.310714285714286*(t-3)^2+.103571428571429*(t-3)^3);




piecewise(t < 1., .953571+.139286*t^2, t = 1., Float(undefined), t < 2., .814286+.278571*t-.696429*(t-1.)^2, t = 2., Float(undefined), t <= 3., 2.90357-1.11429*t+.246429*(t-2.)^2, 3. < t, 1.67143-.621429*t+.310714*(t-3.)^2);


Not defined at t=1 and t=2. Is it possible to get an interpolation of which the first derivative exists at every point? Thank you very much!


I have this code generating a piecewise function:

> with(CurveFitting);

> points := [[0, 1], [1, 2.5], [3, 2.3], [4.2, 5], [5, 3.5], [5.8, 4.2], [7, 7], [8, 10]];

> splcurve := Spline(points, v);

In this particular case I have seven distinct polynomials. Someone knows how could I get one specific polynomial, for example, the one exactly before v < 4.2? 

In other terms:

I'd like to define a new function, say 'f', that is exactly the polynomial just before v < 4.2 (e.g, something like f:=(splcurve, v < 4.2)). Do exists this possibility? (I have been looking for it elsewhere but without success!!)

Thanks in advance! Best regards!


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.


I have to show cubicspline(...) and some kind of known function on the same axis, but it seems I can only show cubicspline(..) using Draw, but it cannot plot the function, so I can do only one at a time. Does anyone know how to do it?

Hello, Mapleprimes' users.


I am using spline to fit a function to a given data (instead of polynomial). I created two examples with data of y=cos(x). 

The first example has a domain X=0..10 and its result is satisfactory.

Ths second example has a larger domain, X=0..15, but I couldn't plot the spline function. The function fits well, but its line ends at X=~10.

Then I ckecked this spline assigning several values of X, and all the results are correct. The problem is on the plot step.

My mw file is:

> restart;
> with(plots);
> with(CurveFitting);
> plotsetup(default);

First Exemple Data (Y=cos(X)):
> X := [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
> Y := [1, .54, -.41, -.99, -.65, .28, .96, .75, -.14, -.91, -.83];
> Piece1 := spline(X, Y, x, 2);
> fig1 := plot(Piece1, view = [0 .. 15, -1 .. 1]);
> fig2 := pointplot(X, Y);
> display(fig1, fig2);
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Second Example Data (Y=cos(X))::
> X := [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15];
> Y := [1, .54, -.41, -.99, -.65, .28, .96, .75, -.14, -.91, -.83, 0., .84, .91, .13, -.76];
> Piece2 := spline(X, Y, x, 2);
> fig3 := plot(Piece2, view = [0 .. 15, -1 .. 1]);
> fig4 := pointplot(X, Y);
> display(fig3, fig4);
> test := unapply(Piece2, x);
> test(15);

    test(15)=-0.76    #correct value!


My actual problem involves data from X=0 to X=300, and I have the same issue in this case.



I'm trying to fit a spacecurve onto some points I have. 

I know, I can use Spline to do this in 2D, but it doesn't work in 3D.

What command(s) can I use to fit a spacecurve onto my points? 

Thanks in advance

well i know this blog is for maple problems and question but badly need your help guys. i want to know difference between cubic spline and cubic b-spline in simple words..


Can you make geometric figures that hold a particular area within a given perimeter of 12 matches

My attempt was to start at origin 0,0 and move up 1 unit (a,b) and then 1 unit up or to the right (c,d) etc ... until you enclose the required area (defined by linear spline) s.t. perimeter =12. but it doesn't really work

Hi friends. Am trying to plot a graph that shows the difference between cubic spline, crank 
nicolson and exact soution in 2d through this command but am not able to get it. 
Whereas table is mentioned below at t=0.05
x	cubic	 crank	  exact
0.05 0.0879 0.0855 0.0756
0.15 0.2514 0.2446 0.2194
0.25 0.3807 0.3708 0.3417
0.35 0.4625 0.4512 0.4305
0.45 0.4928 0.4815 0.4773
0.55 0.4747 0.4646 0.4733
0.65 0.4151 0.4609 0.4305

Hello everyone,

I have data in Excel sheet. I want to make the data smooth using cubic spline. 

My try can be found in the attached maple sheet. In my try, i was unable to see the

difference bewteen the exact data and the interpolated data. Please have a look and

help to smooth the given data in the attached Excel sheet.

1 2 Page 1 of 2