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

Notification

Icon
Error

14 Pages<1234>»
Options
Go to last post Go to first unread
Offline kilele  
#21 Posted : 07 September 2012 22:20:39(UTC)
kilele


Rank: Advanced Member

Groups: Registered
Joined: 30/03/2011(UTC)
Posts: 393

Was thanked: 133 time(s) in 114 post(s)
hey w3b5urf3e, I see on the pic that you want to implement Brent, what about the BDQRF method mentioned on your Bisection testings file? they state that BDQRF is better than Brent
Offline kilele  
#22 Posted : 08 September 2012 00:12:51(UTC)
kilele


Rank: Advanced Member

Groups: Registered
Joined: 30/03/2011(UTC)
Posts: 393

Was thanked: 133 time(s) in 114 post(s)
Originally Posted by: omorr Go to Quoted Post

I also agree about the mentioned observation on the 20-page of your reference. This is up to the user. A simple advice is to rearrange the function f(x)= 0 by avoiding division of terms when denominator can be close to zero.


On that paper (20-page and following) the author also mentions "homotopy continuation methods" to get a good initial guess value. Since initial guess values on multidimensional non-linear systems can be difficult to find and a bad initial guess may cause divergence, maybe it'd be useful to make some initialization function for this golden plugin that w3b5urf3r is preparing Clap
Some simple continuation method would suffice for a good initial value.
Offline omorr  
#23 Posted : 08 September 2012 17:28:39(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 w3b5urf3r
Originally Posted by: w3b5urf3r_reloaded Go to Quoted Post
...about eval(), you cannot use it where there are undefined variables because the function "force" the numeric evalutation.

I am trying to figure out this regarding eval(). I do not get it. It is quite not logical to me. For instance, we can make a function in this way

f(x):line(a:x,y:eval(a^2+5*a-3),2,1)

We can call it and get the result

f(-2)=-9 f(2)=11

But can not use it here

Bisection(f(x#),-9,0,10^{-5},50)=#@#

If we remove eval(), everything is fine

f(x):line(a:x,y:a^2+5*a-3,2,1)

Bisection(f(x#),-9,0,10^{-5},50)=-5.5414

There are functions like Bisection() that actually need the function value regardless the expression behind that function. Moreover, eval() has proven to be sometimes very useful in order to increase the calculation speed dramatically. I think this would be quite a restriction if we could not use it in the situation like these. I suppose that is due to the SMath design and its symbolic engine. I think this is quite a disadvantage regarding the strictly numerical computations and just hope that something could be done about it.

Regards,
Radovan

Edited by user 08 September 2012 17:59:00(UTC)  | Reason: Not specified

When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline Davide Carpi  
#24 Posted : 08 September 2012 19:54:27(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,713
Man
Italy
Location: Italy

Was thanked: 1378 time(s) in 902 post(s)
Plugin updated,

Added new functions (Secant/Brent/Ridder)

The issue of the last post was in the evaluation of the number of functions, now is fixed.

Originally Posted by: omorr Go to Quoted Post
Hello w3b5urf3r
Originally Posted by: w3b5urf3r_reloaded Go to Quoted Post
...about eval(), you cannot use it where there are undefined variables because the function "force" the numeric evaluation.

I am trying to figure out this regarding eval(). I do not get it. It is quite not logical to me. For instance, we can make a function in this way

f(x):line(a:x,y:eval(a^2+5*a-3),2,1)

We can call it and get the result

f(-2)=-9 f(2)=11

But can not use it here

Bisection(f(x#),-9,0,10^{-5},50)=#@#

If we remove eval(), everything is fine

f(x):line(a:x,y:a^2+5*a-3,2,1)

Bisection(f(x#),-9,0,10^{-5},50)=-5.5414

There are functions like Bisection() that actually need the function value regardless the expression behind that function. Moreover, eval() has proven to be sometimes very useful in order to increase the calculation speed dramatically. I think this would be quite a restriction if we could not use it in the situation like these. I suppose that is due to the SMath design and its symbolic engine. I think this is quite a disadvantage regarding the strictly numerical computations and just hope that something could be done about it.

Regards,
Radovan


doing a few tests seem that the eval() function force a "local" numeric evaluation... when a 1st function call a 2nd nested function that contains the eval(), SMath first attempt to evaluate the eval() inside the 2nd function, or something similar... f.e. look the attachment eval.sm, f1a() can't be evaluated simbolically.

As for Primer65aa, the Broyden function is not bugged... the f() function contains logharitms and the Broyden function shoot solutions in the undefined domain (see the attachments).

Originally Posted by: kilele Go to Quoted Post
hey w3b5urf3e, I see on the pic that you want to implement Brent, what about the BDQRF method mentioned on your Bisection testings file? they state that BDQRF is better than Brent


I've seen the BDQRF pseudocode, I think that could be implemented in the next plugin relase, as well as the Zhengqiu Zhang Improvement to the Brent’s Method



regards,

w3b5urf3r

Edited by user 18 September 2012 01:32:07(UTC)  | Reason: Not specified

File Attachment(s):
Primer65aa_debug.sm (56kb) downloaded 51 time(s).
eval.sm (6kb) downloaded 50 time(s).
Davide Carpi attached the following image(s):
primer.png
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
thanks 1 user thanked Davide Carpi for this useful post.
on 08/09/2012(UTC)
Offline omorr  
#25 Posted : 08 September 2012 21:56:32(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 w3b5urf3r,

Thank you for your explanation and the updated plugin Biggrinancing:

Best Wishes,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline omorr  
#26 Posted : 09 September 2012 15:30:33(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,

Here is another file attached. I was struggling with it and it suits me quite well for my classes. As this plugin is about nonlinear solvers, I used in my file a simple Levenberg-Marqurdt based procedure to obtain curve fitting nonlinear in the unknown parameters. It is quite unsophisticated, I have to play with dumping parameters - but it is solving my problem.

As one of my files motivated this plugin, I really hope that this one will do the same as well Good
I would not mind some derivation free optimization (minimization) functions in the plugin like BFGS or Nelder-Mead Biggrin .

Regards,
Radovan

Edited by user 09 September 2012 16:04:47(UTC)  | Reason: Not specified

File Attachment(s):
NLMinimization-3.sm (80kb) downloaded 81 time(s).
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline Davide Carpi  
#27 Posted : 10 September 2012 21:15:57(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,713
Man
Italy
Location: Italy

Was thanked: 1378 time(s) in 902 post(s)
Plugin updated.

Added the Newton-Raphson method for Nonlinear systems of equations and the Bisected Direct Quadratic Regula Falsi method.


regards,

w3b5urf3r



If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
thanks 1 user thanked Davide Carpi for this useful post.
on 10/09/2012(UTC)
Offline kilele  
#28 Posted : 10 September 2012 22:52:45(UTC)
kilele


Rank: Advanced Member

Groups: Registered
Joined: 30/03/2011(UTC)
Posts: 393

Was thanked: 133 time(s) in 114 post(s)
Originally Posted by: omorr Go to Quoted Post

I would not mind some derivation free optimization (minimization) functions in the plugin like BFGS or Nelder-Mead Biggrin .

There you have more matlab code by Kelley for Nelder-Mead and BFGS
( see bfgswopt.m ; nelder.m ; simpgrad.m )

As for "homotopy continuation methods" I've found this mathematica code.
However I don't know if this method is interesting or too difficult to code, I read that works very well for polynomial systems as well.

EDIT:

More fortran and pseudocode about continuation methods on this pdf

Edited by user 11 September 2012 01:13:43(UTC)  | Reason: Not specified

thanks 2 users thanked kilele for this useful post.
on 10/09/2012(UTC),  on 11/09/2012(UTC)
Offline omorr  
#29 Posted : 10 September 2012 23:05:09(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 w3b5urf3r,

Do not have anything to say, but keep up this way Good

I hope you would not mind if I suggest you to change your convergence criterion in the root finding functions.
The convergence criterion at the moment is that the absolute function value in some iteration to be smaller than epsilon


abs(f(P3))<epsilon

This is the simplest convergence criterion. Sometimes it is not good enough. To make that stronger you could add, for instance, that the absolute relative difference of two iteration be smaller than epsilon as well.


(abs(f(P3))<epsilon)&(abs({P3-P2}/{P3+epsilon})<epsilon)

The epsilon in the denominator is in the case the solution is zero.

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline omorr  
#30 Posted : 10 September 2012 23:08: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)
Originally Posted by: kilele Go to Quoted Post
Originally Posted by: omorr Go to Quoted Post

I would not mind some derivation free optimization (minimization) functions in the plugin like BFGS or Nelder-Mead Biggrin .

There you have more matlab code by Kelley for Nelder-Mead and BFGS
( see bfgswopt.m ; nelder.m ; simpgrad.m )

As for "homotopy continuation methods" I've found this mathematica code.
However I don't know if this method is interesting or too difficult to code, I read that works very well for polynomial systems as well.

Thank you, but the second link is broken (mathematica code). Could you check it out.

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline Davide Carpi  
#31 Posted : 11 September 2012 00:24:26(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,713
Man
Italy
Location: Italy

Was thanked: 1378 time(s) in 902 post(s)
Originally Posted by: w3b5urf3r_reloaded Go to Quoted Post
Plugin updated.

Added the Newton-Raphson method for Nonlinear systems of equations and the Bisected Direct Quadratic Regula Falsi method.

regards,

w3b5urf3r



Blush I've forgot to swap the indices of the jacobian derivatives after the debugging, plugin reupdated...


Originally Posted by: omorr Go to Quoted Post
Hello w3b5urf3r,

Do not have anything to say, but keep up this way Good

I hope you would not mind if I suggest you to change your convergence criterion in the root finding functions.
The convergence criterion at the moment is that the absolute function value in some iteration to be smaller than epsilon

abs(f(P3))<epsilon

This is the simplest convergence criterion. Sometimes it is not good enough. To make that stronger you could add, for instance, that the absolute relative difference of two iteration be smaller than epsilon as well.

(abs(f(P3))<epsilon)&(abs({P3-P2}/{P3+epsilon})<epsilon)

The epsilon in the denominator is in the case the solution is zero.

Regards,
Radovan


I know, but I'm trying to pay attention to the management of functions with unit of measurement... although I have not advertised this behavior, actually all solvers shown below works also with units. Introducing new covengence criteria preserving this aspect implies a more advanced error handling (and developping time)...


regards,

w3b5urf3r

Edited by user 11 September 2012 02:36:31(UTC)  | Reason: Not specified

Davide Carpi attached the following image(s):
tollerance handling.PNG
units.PNG
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
Offline kilele  
#32 Posted : 11 September 2012 01:15:46(UTC)
kilele


Rank: Advanced Member

Groups: Registered
Joined: 30/03/2011(UTC)
Posts: 393

Was thanked: 133 time(s) in 114 post(s)
Originally Posted by: omorr Go to Quoted Post

the second link is broken (mathematica code). Could you check it out.


Link corrected and added another pdf resource
Offline omorr  
#33 Posted : 11 September 2012 08:19: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: w3b5urf3r_reloaded Go to Quoted Post
I know, but I'm trying to pay attention to the management of functions with unit of measurement... although I have not advertised this behavior, actually all solvers shown below works also with units. Introducing new covengence criteria preserving this aspect implies a more advanced error handling (and developping time)...

You are right and I respect that Good

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline Davide Carpi  
#34 Posted : 13 September 2012 01:35:32(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,713
Man
Italy
Location: Italy

Was thanked: 1378 time(s) in 902 post(s)
Originally Posted by: kilele Go to Quoted Post
Originally Posted by: omorr Go to Quoted Post


As for "homotopy continuation methods" I've found this mathematica code.
However I don't know if this method is interesting or too difficult to code, I read that works very well for polynomial systems as well.

EDIT:

More fortran and pseudocode about continuation methods on this pdf



little experiments in SMath with Homotopy... it's a very interesting and powerful tool Cool


regards,

w3b5urf3r

Davide Carpi attached the following image(s):
homotopy - function.png
homotopy - systems.png
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
thanks 1 user thanked Davide Carpi for this useful post.
on 13/09/2012(UTC)
Offline omorr  
#35 Posted : 13 September 2012 15:51:55(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,

Some more testings and surprises. I attached one of my files and tried all the nonlinear solvers including the SMath solve, roots() and all of them made by w3b5urf3r up to now Good

I attached a part of my file (primer63w.sm). Here is another situation regarding SMath optimization. The first picture is when the Symbolic Optimization of the function is applied. Everything seems to be fine (although two functions failed - roots(),NewtonRaphosn()). Strangely, when the Optimization is none, numeric - all of them failed and just look at the second picture - now the result of f(1000) is a vector and not scalar as before. This is due to the situation where we have the product of two vector - the result should be a scalar (scalar product of two vectors). When we change some Optimization in the file we can even get the result as in the third picture - solve() gave the result but the other two solvers have different results than solve(). Something must be strange here because other solvers failed. The main problem here is that SMath sometimes returns scalar and sometimes vector depending on optimization applied (fourth and fifth picture on the next post). I think I made some mistakes but can not figure out what happened here.

Could someone take a look at this please.

Regards,
Radovan

Edited by user 13 September 2012 18:51:49(UTC)  | Reason: Not specified

File Attachment(s):
Primer63w.sm (34kb) downloaded 46 time(s).
omorr attached the following image(s):
Primer63w-1.png
Primer63w-2.png
Primer63w-3.png
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline omorr  
#36 Posted : 13 September 2012 15:57:18(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)
Continuing from the post above with two pictures - the result is scalar or vector of scalar product of two vectors - depending on optimization. Do not know why?.

Edited by user 13 September 2012 16:05:44(UTC)  | Reason: Not specified

omorr attached the following image(s):
Primer63w-4.png
Primer63w-5.png
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline Davide Carpi  
#37 Posted : 13 September 2012 21:12:44(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,713
Man
Italy
Location: Italy

Was thanked: 1378 time(s) in 902 post(s)
Hi omorr Good

seems there are many little issues (see the attachment)...

if you use a line in the definition of funh(T), the behavior changes further Grabli


regards,

w3b5urf3r
File Attachment(s):
Primer63w_debug.sm (103kb) downloaded 47 time(s).
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
Offline omorr  
#38 Posted : 13 September 2012 21:42:58(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 w3b5urf3r,

Thank you for checking this out Good . I can join you with "don't know why" statements about this. I am not sure but I think that has something to this Transpose-functions-bug

I hope that Andrey will have some time to check this out as well.

Regards,
Radovan

EDIT: I might be completely wrong here but I think if eval() could be used in funh():=eval(...) many of the numerical problems might be overcome.

Edited by user 14 September 2012 10:57:57(UTC)  | Reason: Not specified

When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline Davide Carpi  
#39 Posted : 14 September 2012 13:25:16(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,713
Man
Italy
Location: Italy

Was thanked: 1378 time(s) in 902 post(s)
Plugin updated.

added HRE(...) and HRE.B(...) (Homotopy root estimation using NewtonRaphson and Broyden, respectively);

fixed issues of internal variable parser with differentiations.

EDIT: Plugin reuploaded with support for unassigned variables named with apostrophe (f.e. x')


regards,

w3bsurf3r

Edited by user 15 September 2012 00:19:20(UTC)  | Reason: Not specified

If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
thanks 1 user thanked Davide Carpi for this useful post.
on 14/09/2012(UTC)
Offline omorr  
#40 Posted : 14 September 2012 23:07:35(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 w3bsurf3r,

Let's go again with testing Good

I attached a file where all solvers failed. Do not understand why. Could you take a look at it please.

Regards,
Radovan
File Attachment(s):
Primer43w.sm (34kb) downloaded 45 time(s).
omorr attached the following image(s):
Primer43w.png
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Users browsing this topic
14 Pages<1234>»
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.