Differentiation of splines

Differentiation of splines - An example - Сообщения

#1 Опубликовано: 08.05.2013 06:49:38
Radovan Omorjan

Radovan Omorjan

325 сообщений из 2052 понравились пользователям.

Группа: Moderator

Hello,

Here is another example I wanted to solve for a long time in SMath. Actually, you can not have a real numerical derivatives in SMath and I also mentioned that few times. If the expression is a bit more complex, there is quite a chance of getting into trouble with derivatives. Moreover, you can not find numerical derivatives of a spline function in SMath. Here is an example where I used Gradient.CD() from the BETANonlinearSolvers (see this thread - this plugin includes many other "derivative free" numerical procedures). I do not know any other more elegant way to solve these kind of problems in SMath. Although it was mentioned here BETANonlinearSolvers among many other things, I just put this example here because I wanted to get it into attention once more.

Regards,
Radovan
interpdiff.sm (12 КиБ) скачан 107 раз(а).
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
1 пользователям понравился этот пост
Davide Carpi 08.05.2013 06:55:00
#2 Опубликовано: 08.05.2013 09:24:04
Oscar Campo

Oscar Campo

124 сообщений из 298 понравились пользователям.

Группа: Moderator

Thanks Omorr, really it's an elegant form.
I'm trying to work with your file but the solve function gives me a "index out of matrix bounds" error, you know what would be the problem?

Regards,

Oscar
#3 Опубликовано: 08.05.2013 11:39:49
Radovan Omorjan

Radovan Omorjan

325 сообщений из 2052 понравились пользователям.

Группа: Moderator

Hello Oscar,
Wrote

Thanks Omorr, really it's an elegant form.
I'm trying to work with your file but the solve function gives me a "index out of matrix bounds" error, you know what would be the problem?


I do not know, sorry. It works for me. Actually, my point was that the differentiation in SMath is problematic - actually there is no pure numerical differentiation at all (there is a numerical integration procedure but SMath's symbolic engine does not have symbolical integration yet). If you want to solve a nonlinear equation, just use the mentioned plugin (SMath's solve() and roots() might give us a hedeack sometimes ). There are many functions for this problem. Here is the previous example with the functions for the nonlinear equation solving from the mentioned plugin.

Regards,
Radovan
interpdiff-1.png
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#4 Опубликовано: 08.05.2013 14:00:14
Oscar Campo

Oscar Campo

124 сообщений из 298 понравились пользователям.

Группа: Moderator

Ok, Omorr,
My problem is due to optimization type. For me, your file only works with "optimization none" except for Brent method, which doesn't works with none optimization method.
#5 Опубликовано: 08.05.2013 14:17:59
Radovan Omorjan

Radovan Omorjan

325 сообщений из 2052 понравились пользователям.

Группа: Moderator

Wrote

Ok, Omorr,
My problem is due to optimization type. For me, your file only works with "optimization none" except for Brent method, which doesn't works with none optimization method.


Sorry, I do not know what is the reason of this behavior

Regards,
radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#6 Опубликовано: 08.05.2013 15:04:31
kilele

kilele

133 сообщений из 397 понравились пользователям.

Группа: User

Wrote

Ok, Omorr,
My problem is due to optimization type. For me, your file only works with "optimization none" except for Brent method, which doesn't works with none optimization method.



Did you installed customFunctions plugin ? it is required for the beta version.
You may want to try the mono version until Davide and Andrey publish the stable versions, I guess your problems might be related to having several installations.
#7 Опубликовано: 08.05.2013 15:48:25
Oscar Campo

Oscar Campo

124 сообщений из 298 понравились пользователям.

Группа: Moderator

Wrote

Did you installed customFunctions plugin ? it is required for the beta version.
You may want to try the mono version until Davide and Andrey publish the stable versions, I guess your problems might be related to having several installations.



Yes, I have this plugin installed and also the another ones are updated. I don't know way this issue happens
#8 Опубликовано: 15.09.2015 23:59:18
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Hello,

Here is another example I wanted to solve for a long time in SMath. Actually, you can not have a real numerical derivatives in SMath and I also mentioned that few times. If the expression is a bit more complex, there is quite a chance of getting into trouble with derivatives. Moreover, you can not find numerical derivatives of a spline function in SMath. Here is an example where I used Gradient.CD() from the BETANonlinearSolvers (see this thread - this plugin includes many other "derivative free" numerical procedures). I do not know any other more elegant way to solve these kind of problems in SMath. Although it was mentioned here BETANonlinearSolvers among many other things, I just put this example here because I wanted to get it into attention once more.

Regards,
Radovan
____________________________________________________

Hello Radovan,

linterp, cinterp, aiterp are strictly interpolating functions in Smath.
Most evidently from old codes from times numerical methods didn't exist.
It is on my RemToDo from Mathcad. It might be possible to convert.
If successful, cubic splines will be true scalar functions.
On the other end, linterp as a function is just useless for derivatives
because linterp as a function is not analytical up to 2nd order derivatives.
To the contrary, scalar cubic spline is analytical.
In fact, cubic spline has little interst unless you have clean data set from
functions. But that is sratching the left ear with the right hand.
Again, sampled data sets are naturally noisy from the quantizing numerical
capture as well as from the nature of the experiment. That means that for
derivative, you must smooth in some way, otherwise green grass wlii grow in
your work sheet.
To the contrary of the derivative monkey business, integration of noisy
sampled data sets come out of clicking fingers with extraordinary perfection.
A while ago, I posted the finite differences derivatives & integration.

Cheers Collab, nice to read you.

Jean

#9 Опубликовано: 16.09.2015 03:55:37
Radovan Omorjan

Radovan Omorjan

325 сообщений из 2052 понравились пользователям.

Группа: Moderator

Hello Jean,

Thank you for your comment, and I hope I understood your point.

I agree with you that if you have a noisy cloud of data, the things are going to be problematic in SMath. As you said "scratching the left ear with the right hand" . As far as I know, there is no smoothing functions present in SMath yet. I know that integration and differentiation of noisy data are quiet standard procedures, but if you like to do that in SMath - you have to think twice.

As far as I know, there is no smoothing functions present yet.

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#10 Опубликовано: 17.09.2015 01:55:51
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

No matter how much maths you will attempt,
basic cubic spline are NOT differentiable.

In there, if the data points would be "exact"
error in the fit is acceptable for practical use.

Jean
Polynomial fit_D[x].sm (17 КиБ) скачан 76 раз(а).
2 пользователям понравился этот пост
NDTM Amarasekera 17.09.2015 03:26:00, Davide Carpi 17.09.2015 03:57:00
#11 Опубликовано: 17.09.2015 11:03:58
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Hello Radovan,

I got deceived by "ainterp", it does a por job on few points, Ah !
It may have unxplored utilities.

BTW: The XY plot is not the gear to plot: linterp, ainterp, cinterp
The XY plot is strictly limited to plot "true function(s)".
Basically, it plot some default number [maybe 99]of linear segments
It has an unknown spline joint [OriginLab style], thus it plots
crappy stuff. From recollection, Excel joints Bézier ?

More spline is RemToDo [sometimes].

Cheers Collab(s), Jean
Utilities XY plot.sm (16 КиБ) скачан 63 раз(а).
1 пользователям понравился этот пост
Radovan Omorjan 17.09.2015 13:34:00
#12 Опубликовано: 24.09.2015 22:38:39
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Differentiation of splines is all done in the thread "Cubic Splines Read More"
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений