Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Login


Options
Go to last post Go to first unread
Offline Razonar  
#1 Posted : 28 August 2018 20:25:31(UTC)
Razonar


Rank: Advanced Member

Groups: Registered
Joined: 28/08/2014(UTC)
Posts: 1,356
Uruguay

Was thanked: 815 time(s) in 516 post(s)
Hi. I have some issues in the attached.

Thanks in advance.

Alvaro.

cspline test.sm (38kb) downloaded 41 time(s).

Wanna join the discussion?! Login to your SMath Studio Forum forum account. New Registrations are disabled.

Offline Jean Giraud  
#2 Posted : 28 August 2018 21:12:16(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,868
Canada

Was thanked: 980 time(s) in 808 post(s)
Originally Posted by: Razonar Go to Quoted Post
Hi. I have some issues in the attached.

Thanks in advance.

Alvaro.


Two red remain ... but here the XY plot.

Cheers, Jean

Alvaro.PNG

cspline test.sm (43kb) downloaded 28 time(s).

thanks 1 user thanked Jean Giraud for this useful post.
on 28/08/2018(UTC)
Offline Razonar  
#3 Posted : 28 August 2018 21:20:11(UTC)
Razonar


Rank: Advanced Member

Groups: Registered
Joined: 28/08/2014(UTC)
Posts: 1,356
Uruguay

Was thanked: 815 time(s) in 516 post(s)
Hi Jean. Thanks, but you know me ... I want to use my own function.

Best regards.

Alvaro.
Offline omorr  
#4 Posted : 28 August 2018 22:17:14(UTC)
omorr


Rank: Administration

Groups: Registered, Advanced Member
Joined: 23/06/2009(UTC)
Posts: 1,740
Man
Serbia

Was thanked: 318 time(s) in 268 post(s)
Two red will disappear if you use for loops instead of vectorization.

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
thanks 1 user thanked omorr for this useful post.
on 29/08/2018(UTC)
Offline Jean Giraud  
#5 Posted : 29 August 2018 06:35:12(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,868
Canada

Was thanked: 980 time(s) in 808 post(s)
Originally Posted by: Razonar Go to Quoted Post
Hi Jean. Thanks, but you know me ... I want to use my own function.


I messed your coding to make readable.
As it looks, you seem to implement Hermite cubic or an unknown brew ?
Hermite [the Draftsman spline] fits better in certain region,
but is discontinuous at junctions and as such has little interest.
In short, it can be used to create some additional best points
for the next more conventional l_p_c splines, for them now to
be continuous at points, thus analytical up to 2nd order derivative.
Hermite was exhausted in Mathcad, all converted Smath.
If of interest, will be please to attach.
Your original coding did calculate 'V' , but not the freaked code.
Some sort of "shadow in context".

Jean

cspline test[NFG].sm (54kb) downloaded 20 time(s).
Spline l_p_c [dspline, fintegrate].sm (79kb) downloaded 19 time(s).
Spline l_p_c [Recovered].sm (130kb) downloaded 20 time(s).



Offline Razonar  
#6 Posted : 29 August 2018 08:49:38(UTC)
Razonar


Rank: Advanced Member

Groups: Registered
Joined: 28/08/2014(UTC)
Posts: 1,356
Uruguay

Was thanked: 815 time(s) in 516 post(s)
Hi Jean. There are not to much shadow in that small code. It's just the implementation of the traditional spline interpolation. In SMath there are not, or I can't found, the function cspline. The interpolation with cinterp in SMath evaluates the vector V each time that you call it, it's always better to have V=cspline(X,Y) and then call interp(V,X,Y,x). Finally, I want to implement an adaptive step size for the intervals in X. But first I see very convenient to have vectorization and plotting issues solved.

CS only do what mathcad's cspline do:

Clipboard01.jpg

Best regards.
Alvaro.
Offline Jean Giraud  
#7 Posted : 29 August 2018 22:16:49(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,868
Canada

Was thanked: 980 time(s) in 808 post(s)
Originally Posted by: Razonar Go to Quoted Post
Hi Jean. There are not to much shadow in that small code. It's just the implementation of the traditional spline interpolation. In SMath there are not, or I can't found, the function cspline. The interpolation with cinterp in SMath evaluates the vector V each time that you call it, it's always better to have V=cspline(X,Y) and then call interp(V,X,Y,x). Finally, I want to implement an adaptive step size for the intervals in X. But first I see very convenient to have vectorization and plotting issues solved.

CS only does what Mathcad's cspline does:


The interpolation with cinterp in SMath evaluates the vector V each time that you call it, it's always better to have V=cspline(X,Y) and then call interp(V,X,Y,x)


1. You have a good point, but invalid: cinterp(X,Y,x) works faster than Mathcad [I tested long time ago].
2. Not supporting vectorization has only one answer to me:
all that stuff is scalar wrt 'x' for the canvas plot only,
but it is NOT a real scalar function like the built-in ones ... sin(x), cos(x), exp(x) ...
3. For the adaptive step size, you may have to invent the wheel or implement
Robert A. [Lagrange quadratic knots ... stricking example attached].

Resume:
1. cinterp => hyperfast
2. Vectorization ... left unsolved
3. adaptive step size => suggested

Thanks Alvaro, most interesting ... Jean

cspline test (1).sm (63kb) downloaded 29 time(s).
Spline Lagrange [Quadratic knots EXPERIMENTAL].sm (48kb) downloaded 25 time(s).
Offline Razonar  
#8 Posted : 31 August 2018 07:21:49(UTC)
Razonar


Rank: Advanced Member

Groups: Registered
Joined: 28/08/2014(UTC)
Posts: 1,356
Uruguay

Was thanked: 815 time(s) in 516 post(s)
CSplines with adaptive steps. Same issues, but now can use zero with units, at least in the adaptive case.

Best regards.
Alvaro.

adapt cspline test.sm (84kb) downloaded 31 time(s).
Offline omorr  
#9 Posted : 31 August 2018 09:27:53(UTC)
omorr


Rank: Administration

Groups: Registered, Advanced Member
Joined: 23/06/2009(UTC)
Posts: 1,740
Man
Serbia

Was thanked: 318 time(s) in 268 post(s)
Originally Posted by: Jean Giraud Go to Quoted Post

...
Resume:
1. cinterp => hyperfast
2. Vectorization ... left unsolved
3. adaptive step size => suggested
...


I will add this as well, if you do not mind.

Two of the main reasons we want to use interpolation (cinterp f.e.).
I think I mentioned this many times...
...
4. numerical derivation ... left unsolved
5. numerical integration => solved?
....

Regards,
Radovan

Edited by user 31 August 2018 09:34:03(UTC)  | Reason: Not specified

When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline Jean Giraud  
#10 Posted : 31 August 2018 19:29:14(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,868
Canada

Was thanked: 980 time(s) in 808 post(s)
Originally Posted by: omorr Go to Quoted Post
I will add this as well, if you do not mind.

Two of the main reasons we want to use interpolation (cinterp f.e.).
I think I mentioned this many times...
...
4. numerical derivation ... left unsolved
5. numerical integration =


Numerical derivation from the Smath d/dx is not possible ... WHY ?

The derivative operator derives wrt to rules that apply to function(s)
cinterp(X,Y,x) is not a function, only an interpolating function.
Alternately two ways:
1. from the dspline(s,X,Y,t) ... 's' from solving
2. from the infinitesimal D1(x,h,f) ... where 'f' is cinterp(X,Y,x)

Exemplified in the attached ... Jean

Page0 Cubic Copy.sm (105kb) downloaded 18 time(s).
Offline Razonar  
#11 Posted : 31 August 2018 22:34:07(UTC)
Razonar


Rank: Advanced Member

Groups: Registered
Joined: 28/08/2014(UTC)
Posts: 1,356
Uruguay

Was thanked: 815 time(s) in 516 post(s)
Derivative and integral for regular cubic splines.
Best regards.
Alvaro.

di cspline test.sm (87kb) downloaded 48 time(s).
Offline Jean Giraud  
#12 Posted : 02 September 2018 18:01:07(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,868
Canada

Was thanked: 980 time(s) in 808 post(s)
Originally Posted by: Razonar Go to Quoted Post
Derivative and integral for regular cubic splines.
Best regards.
Alvaro.


1. Integrator does not recognize p(x)
2. D2(,x) works great.

Cheers ... Jean

di cspline test Otherwise.sm (52kb) downloaded 23 time(s).
di cspline test.sm (102kb) downloaded 22 time(s).

Offline Jean Giraud  
#13 Posted : 03 September 2018 00:12:38(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,868
Canada

Was thanked: 980 time(s) in 808 post(s)
Originally Posted by: Jean Giraud Go to Quoted Post
Derivative and integral for regular cubic splines.
Best regards.
Alvaro.

1. I don't think you have any kind of spline for real application [added example].
2. From what I tested before Smath cinterp is universal [Matlab, Mathematica, Mathcad ...]
3. Read carefully: Smath ainterp [Akima] is unique to me to Smath.
From previous ad nauseum testing, it fits exceptionally well certain types of data
and is pure crap for other types of data, that's what it is. Superb for the example.
4. On the other hand, integrator supports cinterp, your coding does not.
The cumulative integration does between limits as well, just more greedy in time.
5. I don't understand all that crappy coding from download ... damned mystic !

All in all: most interesting. Thanks Alvaro.

di cspline test [SHORT] Copy.sm (105kb) downloaded 30 time(s).



Offline Razonar  
#14 Posted : 06 December 2021 09:21:27(UTC)
Razonar


Rank: Advanced Member

Groups: Registered
Joined: 28/08/2014(UTC)
Posts: 1,356
Uruguay

Was thanked: 815 time(s) in 516 post(s)
Updated (Now it works again). Revised because the new develop of interpolation funcitons by Viacheslav at https://en.smath.com/for...E-Solvers.aspx#post75020

This worksheet is about adaptive csplines and differentiation and integration of the splines.

cspline.sm (107kb) downloaded 33 time(s).

cspline.pdf (298kb) downloaded 14 time(s).

img0.png

Best regards.
Alvaro.
thanks 2 users thanked Razonar for this useful post.
on 06/12/2021(UTC),  on 06/12/2021(UTC)
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.