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 omorr  
#1 Posted : 01 December 2013 13:06:27(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)
Here is the problem I bumped into. I was just playing with Maxima package interpol and find out that it crashes SMath for cspline() and linearinterpol() functions when the Optimization is turned to None. I suppose that the charfun2() causes this problem, but do not know why. Please look at the example and try to turn the optimization to None for the red area. If the Symbolic optimization is on, then the error is issued. If I turned Optimization to None, then SMath crashes on my computer.

Regards,
Radovan

Edited by user 01 December 2013 13:08:57(UTC)  | Reason: Not specified

File Attachment(s):
interpol.sm (9kb) downloaded 23 time(s).
omorr attached the following image(s):
interpol.png
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
thanks 1 user thanked omorr for this useful post.
on 01/12/2013(UTC)

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

Offline mkraska  
#2 Posted : 01 December 2013 14:16:21(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,986
Germany

Was thanked: 1124 time(s) in 721 post(s)
On my computer (x64, win 7) setting opt to none in your example just crashes SMath, which is bad enough.

The current plugin version is rather unstable. There are multiple ways to trouble the plugin such that you cannot even recover by MaximaControl("restart" ).

I think we should maintain a stable and a development version in the online gallery.
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
Offline omorr  
#3 Posted : 01 December 2013 14:42:05(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)
Hello Martin,

I am not sure if this particular problem (bug) might be somehow related to the relational operators in Smath and in Maxima (<= etc.). I remembered you mentioned this somewhere, but can not find it where it was at the moment.

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline mkraska  
#4 Posted : 01 December 2013 14:54:24(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,986
Germany

Was thanked: 1124 time(s) in 721 post(s)
Radovan, you are right, part of the problem is that back-translation of relational operators like >= and <= as well as boolean operators like or and and is not yet supported in the plugin. But I shall have a look at charfun, may be that provides a good way to translate Davide's ternary comparison operators to Maxima and back to SMath.

However, the plugin should not crash on unsupported expressions.
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
thanks 1 user thanked mkraska for this useful post.
on 01/12/2013(UTC)
Offline mkraska  
#5 Posted : 02 December 2013 00:06:20(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,986
Germany

Was thanked: 1124 time(s) in 721 post(s)
Preview of partly problem solution. Back-translation of logical expressions is implemented and a the interpol results can be evaluated, plotted and numerically integrated. The plugin, however, does not yet wrap boolean expressions in charfun() when translating to Maxima, therefore such expressions cannot yet be integrated using Maxima's int() version.

It seems that expressions involving charfun() cannot be integrated symbolically using Maxima. Thus there might be a point of transforming boolean expressions to such with sign().

We upload the new plugin version as soon as it passes the regression test. Current state is too unstable.
mkraska attached the following image(s):
spline.PNG
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
thanks 1 user thanked mkraska for this useful post.
on 02/12/2013(UTC)
Offline omorr  
#6 Posted : 02 December 2013 13:30:30(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)
Thank you Martin,

Actually, I was trying to make a function by using cubic spline from interpol package, and to see how to integrate and differentiate the obtained function numerically - everything by using Maxima. I was already mentioned this few times on the Forum. For instance (see this example Differentiation of splines). Unfortunately, this example will not work for me anymore, do not know why.

Regards,
Radovan

EDIT: Try to plot with both SMath genuine plot and X-Y plot. There are the differences I can not explain

Edited by user 02 December 2013 13:48:54(UTC)  | Reason: Not specified

omorr attached the following image(s):
interpdiff-1.png
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline mkraska  
#7 Posted : 02 December 2013 17:24:12(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,986
Germany

Was thanked: 1124 time(s) in 721 post(s)
If you are just up to numeric integration and differentiation of interpolated data, you could sample the interpolation and apply appropriate FIR kernels using uni's alglib functions. Works very well with Savitzky-Golay in matlab.
File Attachment(s):
al_convr1d.sm (22kb) downloaded 18 time(s).
mkraska attached the following image(s):
conv.PNG
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
Offline omorr  
#8 Posted : 02 December 2013 19:53:45(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)
Thank you Martin for this one. The sampling was Ok and worked even with Gradiend.CD() from Davide's plugin and that was not the point. The problem was the plotting and solve() which failed here now. Do not know why. Actually, I have no idea at the moment how to find the zeros of dy(x) function from the example Differentiation of splines (see the picture from the example which worked before - but now failed).

Actually, it is a bit out of the topic regarding the Maxima interpol package - but I can not understand why the plotting does not work anymore and do not understand why solve() failed here. It seems to me that I have the same questions over and over. Sorry If I do not see some obvious things - again.

Regards,
Radovan

The attached sm file will not produce this result for the plot and solve() anymore, as seen in the picture

Edited by user 02 December 2013 20:08:48(UTC)  | Reason: Not specified

File Attachment(s):
interpdiff-1.sm (13kb) downloaded 18 time(s).
omorr attached the following image(s):
interpworked.png
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline mkraska  
#9 Posted : 11 January 2014 03:41:54(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,986
Germany

Was thanked: 1124 time(s) in 721 post(s)
There should be no more crashes due to package interpol now.
File Attachment(s):
Example Maxima interpol.sm (15kb) downloaded 16 time(s).
mkraska attached the following image(s):
interpol.PNG
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
Offline omorr  
#10 Posted : 11 January 2014 12:14:28(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)
Thank you Martin,

Unfortunately, numerical integration in Maxima (quad* set of functions) will not work directly in SMath with this cubic spline. Actually, It must be used this way


Maxima(quad_qags(cspline(M),x,1,3))=sys(6.369565217391301,7.071637942785607*10^{-14},63,0,4,1)

Moreover, when I use Davide's, Gradiend.CD() I can get a function by numerically differentiating - but not its roots. This is a long time story, and I still can not figure out how to deal with this kind of problems in SMath.

Regards,
Radovan

Edited by user 11 January 2014 12:31:10(UTC)  | Reason: Not specified

omorr attached the following image(s):
maxima quad diff.png
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline mkraska  
#11 Posted : 11 January 2014 14:09:28(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,986
Germany

Was thanked: 1124 time(s) in 721 post(s)
Originally Posted by: omorr Go to Quoted Post
Thank you Martin,
Unfortunately, numerical integration in Maxima (quad* set of functions) will not work directly in SMath with this cubic spline.
You have to remove the suppression of charfun() (which I guess - if not bet - is still somewhere in your SMath sheet ;-)
Application and removal of type conversion functions like charfun() should be done in the translation process. This, however, is not yet implememted.

It might be a good idea to use the quadrature functions in Maxima for int() when numeric optimization is requested. This would, of course, require units preprocessing.
mkraska attached the following image(s):
quad.PNG
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
Offline omorr  
#12 Posted : 11 January 2014 14:51:16(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: mkraska Go to Quoted Post
Originally Posted by: omorr Go to Quoted Post
Thank you Martin,
Unfortunately, numerical integration in Maxima (quad* set of functions) will not work directly in SMath with this cubic spline.
You have to remove the suppression of charfun() (which I guess - if not bet - is still somewhere in your SMath sheet ;-)

Yes, you are right - I missed it Grabli

Regards,
Radovan

When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline Jean Giraud  
#13 Posted : 06 August 2015 07:26:11(UTC)
Jean Giraud

Rank: Guest

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

Was thanked: 981 time(s) in 809 post(s)
The latest Maxima 5.34.1 does not have numeric/interpol : tht's the first problem for all viewers.

Maxima cspline is an horrible monkey business probably incompatible with Smath, WHY ?
On the first count: Smath is not a 'scalar' system, only discrete.
Thus it might be impossible to built a scalar cspline that can be assigned as a function
as a function analytical up to the 2nd order derivative.
On the 2nd count: the former Maxima cspline is archaic in the displaying the segments,
just figure splining a data set of small 50 pairs. Again not exportable.

More confusing: Smath f(x) has linterp, ainterp [Akima spline], cinterp
these 3 are LOCAL interpolating functions, i.e: nothing else to do with
except populate data set for export.
_____________________________________________________

The Lagrange interpolation is totally useless. From a data set of length 'n' you can get
an nth order polynomial that will do exactly what your Lagrange interpolation does.
If your data set is like noisy or not so regular [they are always noisy or not very regular
from experimental sampling], the the polynomial fit can be or les order than the 'n' data.
Thus you benefit some smoothing. The polynomial fit need not be of integer monomials
x, x^2, x^3 ... the x's may be of decimal exponents, it may help the fit.

Polynomial fit is just few line of Smath simple coding.
A much, much, much more powerful fitter is the Padé rational fraction, in Mathcad 11, it works
by clicking the fingers. BTW, all [if not all] approximation of functions in computers
are Padé rational fractions [collected in Hart et al.]

jmgiraud@bell.net
Users browsing this topic
Guest
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.