NonlinearSolvers plugin

NonlinearSolvers plugin - BDQRF, Bisection, Brent's, Broyden's, Newton-Raphson, Ridder's, Secant, Homotopy - Messages

#61 Posted: 13 years ago
Вячеслав Мезенцев

Вячеслав Мезенцев

1401 likes in 1707 posts.

Group: Moderator

Posted 

Sorry Uni, I don't understand your pdfs


I'm sorry, maybe it will be clearer: http://stocktrader10.tripod.com/
Quote

This Web site is a good spot to let visitors know the math method developed by Russian scientist Anatoly V.Draghilev
This page was last updated on 06/06/02 .
e-mail :Alexey Ivanov [stitch_design@rambler.ru]



Page 1, page 2, page 3, page 4, page 5

Russia ☭ forever Viacheslav N. Mezentsev
2 users liked this post
Radovan Omorjan 13 years ago, Davide Carpi 13 years ago
#62 Posted: 13 years ago
Вячеслав Мезенцев

Вячеслав Мезенцев

1401 likes in 1707 posts.

Group: Moderator

One more example (rus): link

Russia ☭ forever Viacheslav N. Mezentsev
2 users liked this post
Radovan Omorjan 13 years ago, Davide Carpi 13 years ago
#63 Posted: 13 years ago
Вячеслав Мезенцев

Вячеслав Мезенцев

1401 likes in 1707 posts.

Group: Moderator

And some video:
Russia ☭ forever Viacheslav N. Mezentsev
#64 Posted: 13 years ago
Ioan

Ioan

1 likes in 26 posts.

Group: User

Posted 



Ioan,
[/b]



Hi Ioan

The HRE functions need 2 arguments, no more (see the attachment).

The initial unknown guess strategy It's a common issue, Homotopy and Bisection I think they are the best approaches.

Note that in your script a "large" bound it's better than a little bound.


best regards,

w3b5urf3r

P.S. in the previous post I've reupdated the plugin, the previous librery have a little issue with the x variable, when already defined








Hi w3b5urf3r,



Thanks for your suggestion.

Due to a wide range of parameters, I followed your suggestion by making two steps:
* one to identify the function sign changing and;
* one for finding the right solution.

I included two home-made routines (see attached file), one based on the chord method and the other based on the Newton (Broyden ?) method.

I called the plugin giving to it my initial guess values, the same as for my routines.
I've seen that for some situations no solution is founded with the plugin, while my routines give enough accurate solution.

Of course, I understand that the main objective of the plugin is the equation systems, but I believe that it could be useful also for the particular case of single equations.

Hoping to be useful.


Best regards,

Ioan








longflamb eq mid.sm (40 KiB) downloaded 47 time(s).
#65 Posted: 13 years ago
Radovan Omorjan

Radovan Omorjan

325 likes in 2052 posts.

Group: Moderator

Hello uni,
Posted 

And some video:


I do not know how I did miss that on the Russian side

It is very interesting and I will definitely pay more attention to your posted examples.In the meantime, just wanted to ask something. It might be a stupid question, therefore i excuse myself in advance

You solved few nonlinear systems, nonlinear equations, found the function extrema and it looks, how to say, very exotic
As far as understood at a first glance, to realize this method - functions gradients and solving ODE initial value problem is the main constituent and the main problematic part of the method and of the potential plugin . I might be totally wrong, of course because I did not explore it yet.

I do not know how would this method behave with, say 10x10 system of equations? Do you have any experience with something like this?

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#66 Posted: 13 years ago
алексей

алексей

17 likes in 78 posts.

Group: User

Hello!
One more example, the system was solved by a Draghilev's method for practically all positive (L,x) :
(1+exp(-2*L*x))*cos(L*x)+2*exp(-L*x)=0; http://forum.exponenta.ru/viewtopic.php?p=55406#55406
Excuse me, I do not know English. I think, uni will help me…
Description of the method:
http://forum.exponenta.ru/viewtopic.php?t=3892&start=0&sid=616ac92e0e41288833d51ba26c338d0f
1 users liked this post
Davide Carpi 13 years ago
#67 Posted: 13 years ago
Вячеслав Мезенцев

Вячеслав Мезенцев

1401 likes in 1707 posts.

Group: Moderator

Posted 

You solved few nonlinear systems, nonlinear equations, found the function extrema and it looks, how to say, very exotic
As far as understood at a first glance, to realize this method - functions gradients and solving ODE initial value problem is the main constituent and the main problematic part of the method and of the potential plugin .


Well, I'll explain how it works and what you can do with it. But first I need to finish MapleWrapper plugin.
In order to explain I need the two plugins: ODESolvers and MapleWrapper. One would be to calculate the Jacobian, and the second to solve an ODE. This is not exotic, but rather simple things, as you will see.
Russia ☭ forever Viacheslav N. Mezentsev
1 users liked this post
Radovan Omorjan 13 years ago
#68 Posted: 13 years ago
Radovan Omorjan

Radovan Omorjan

325 likes in 2052 posts.

Group: Moderator

Thank you very much

I am looking forward to it.

By the way, you know that I appreciate very much that you made ODEsolvers plugin. Hope that you would have the time to add some "stiif" ODE solver in the future.

Wish you all the best and good luck

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
1 users liked this post
#69 Posted: 13 years ago
алексей

алексей

17 likes in 78 posts.

Group: User

Posted 

Hello!
One more example, the system was solved by a Draghilev's method for practically all positive (L,x) :
(1+exp(-2*L*x))*cos(L*x)+2*exp(-L*x)=0; http://forum.exponenta.ru/viewtopic.php?p=55406#55406
Excuse me, I do not know English. I think, uni will help me…
Description of the method:
http://forum.exponenta.ru/viewtopic.php?t=3892&start=0&sid=616ac92e0e41288833d51ba26c338d0f



Uni has promised to help with explanations...
System of equations whose solution is converted into an animation of the mechanism.
x1^2+x2^2+(x3+.5*sin(10*x1)-3)^2-4=0;
x2-x1=0;
x5-x6=0;
x5-3=0;
(x1-x4)^2+(x2-x5)^2+(x3-x6)^2-20.1=0;
Maple.Draghilev's method.
#70 Posted: 13 years ago
kilele

kilele

133 likes in 397 posts.

Group: User

@uni

The method you mentioned seems to be the same as the one used in the two pdf papers I linked above, it's an homotopy, differentiated to form an IVP.
One of the pdf I linked contains an implementation of the algorithm solved with classic Runge-Kutta order4 formulas for the IVP (RK4 is said to have a good balance between cost and precision). I'm sure that w3b5rfer might be implementing it for the next version of his plugin.

As for a function for stiff odes, there you have a .NET library (pity it's gpl licensed, at least you can see which algorithms are used).
http://www.dotnumerics.com/NumericalLibraries/DifferentialEquations/Default.aspx


EDIT:
Feel free to contact the author if someone wants to use dotnumerics,
I might be wrong as for the license issues to develop open source plugins for a closed software (though non-comercial) as it is SMath.

EDIT:
I've read that this BDF implementation in C (for Stiff IVP) is good, see "GEAR.H" , "GEAR.CPP" and "MGEAR.CPP"
http://jean-pierre.moreau.pagesperso-orange.fr/c_eqdiff.html
3 users liked this post
Вячеслав Мезенцев 13 years ago, Davide Carpi 13 years ago, Radovan Omorjan 13 years ago
#71 Posted: 13 years ago
Davide Carpi

Davide Carpi

1407 likes in 2870 posts.

Group: Moderator

PLUGIN UPDATED :d

- new feature: solvers for systems of equations now accept multiple unknowns names (introduced in the latest BETA + new fixes);

- Broyden convergence criterion revisited (introduced in the latest BETA);

- added HRE.RK(...) (Homotopy root-estimation method, using the Runge-Kutta 4th order algorithm);

- all homotopy algorithms now works as Broyden() and NewtonRaphson() (4 required arguments and a 5th optional argument - see the attachment);

- previous HRE() renamed as HRE.NR();

- plugin Jacobian(...) unlocked (introduced in the latest BETA + new fixes);

- fixed issues with Units in all HRE() solvers.


regards,

w3b5urf3r
SMath Studio - [HRE_testing.sm].png
If you like my plugins please consider a donation to SMath Studio; for personal contributions to me: paypal.me/dcprojects
1 users liked this post
Radovan Omorjan 13 years ago
#72 Posted: 13 years ago
алексей

алексей

17 likes in 78 posts.

Group: User

The most simple example to illustrate Draghilev's method:
x1^2-x2*x1+x2^2-1=0;
sin(5*x1^2)+sin(4*x2^2)=0;
x01 := 0.;
x02 := 1.;
Maple.
1 users liked this post
#73 Posted: 13 years ago
adiaz

adiaz

5 likes in 25 posts.

Group: User

Very nice work. Just some little observations. You use the same epsilon for both x and y axis. The exit code for some functions is min(y)<epsilon, but i'm think that it could be better to take max(y). For bisection maybe is better not having both epsilon and maxiters, with only one is enough. An exit code of the form abs(x2-x1)<epsilon (actually, norm1 or other) is not pressent in all of the functions. I don't understand the test xlast = x then break, perhapsh it can be xlast < x then break.

Regards.

Alvaro.
#74 Posted: 13 years ago
Radovan Omorjan

Radovan Omorjan

325 likes in 2052 posts.

Group: Moderator

Posted 

PLUGIN UPDATED :d

- new feature: solvers for systems of equations now accept multiple unknowns names (introduced in the latest BETA + new fixes);

- Broyden convergence criterion revisited (introduced in the latest BETA);

- added HRE.RK(...) (Homotopy root-estimation method, using the Runge-Kutta 4th order algorithm);

- all homotopy algorithms now works as Broyden() and NewtonRaphson() (4 required arguments and a 5th optional argument - see the attachment);

- previous HRE() renamed as HRE.NR();

- plugin Jacobian(...) unlocked (introduced in the latest BETA + new fixes);

- fixed issues with Units in all HRE() solvers.



Just a little bit of testing with one my "nightmare" problem. I've mentioned this example already. I think this is one more of the SMath symbolic engine problem, and it my happen that you can define a vector function but can not obtain the Jacobian of it. See the attached file and the picture. I managed to solve this problem initially with HR.B() to get better guess values and then Broyden() could do the job. As I do not know how to force SMath to perform all the symbolic operations (for instance, all the operations inside stack() function - among other things), it seems that HR.B() and Broyden() in these situations are the only way of performing similar things . At the end of the file I did all the things about defining the function manually, and then the situation changed drastically. Anyway, I am satisfied that some progress has been made about this

Regards,
Radovan
Primer4.7w-1.png
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#75 Posted: 13 years ago
Davide Carpi

Davide Carpi

1407 likes in 2870 posts.

Group: Moderator

Hi omorr,

I've seen you're example, unfortunately there are many little "issues" regarding the symbolic engine...

For example observes the first element of your f1(), f2() and f3() (look the attachments);

f1()

SMath seem unable to make a symbolical stack of the function; It's not difficult to understand why... the columns of the results matrix (if all it's correct) are the columns of the last stack argument -> 1; the rows are undefined because if [MATH lang=eng]el(X#,2)[/MATH],[MATH lang=eng]el(X#,4)[/MATH],[MATH lang=eng]el(X#,5)[/MATH] and [MATH lang=eng]el(X#,3)[/MATH] are vectors, the result is a vector... exluding the assumption that all unknown elements are numbers or a "size predeclaring", probably the issue could be solved using a "trial and error" procedure on the unknown size, but I think it's a very hard task

f2()
Here there are SMath issues with derivatives... probably it's the same issue of f3() (and the same of this bug), IMHO all related to the symbolic simplification engine...

f3()
Here there are SMath issues with derivatives and elements...


Since all the issues with derivatives involving the Jacobian, so NewtonRaphson(), HRE.NR() and HRE.RK() in this example can not be used (at the moment, at least)


Posted 

For bisection maybe is better not having both epsilon and maxiters, with only one is enough


I don't agree, because with discontinuous functions (f.e. tan(x)) the maxiters prevents infinite loops.

bisection failure

regards,

w3b5urf3r
Primer4.7w-debug.sm (145 KiB) downloaded 38 time(s).
If you like my plugins please consider a donation to SMath Studio; for personal contributions to me: paypal.me/dcprojects
#76 Posted: 13 years ago
Radovan Omorjan

Radovan Omorjan

325 likes in 2052 posts.

Group: Moderator

Hello w3b5urf3r,

Thank you for your answer an I agree with you completely. We also can see that many of us on this Forum have to many "why?" regarding symbolic engine .

To be honest, Mathcad drives me crazy for almost 25 years and it would be fair that I could give a chance to SMath for the next 20 years or so :d

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#77 Posted: 13 years ago
adiaz

adiaz

5 likes in 25 posts.

Group: User

Posted 



Posted 

For bisection maybe is better not having both epsilon and maxiters, with only one is enough


I don't agree, because with discontinuous functions (f.e. tan(x)) the maxiters prevents infinite loops.
w3b5urf3r



Epsilon and maxiters for bisection is redundant. Even it's more easy with maxiters, is better to take Epsilon (one for each axis, but that is not related with maxiters redundance). In the code maxiters is calculated as N. Actually, the main loop can be implemented with a for loop.

Regards.

Alvaro.
BIS_02.gif
#78 Posted: 13 years ago
алексей

алексей

17 likes in 78 posts.

Group: User

f1 := 3.*x-cos(y*z)-0.5;
f2 := x^2-81.*(y+0.1)^2+sin(z)+1.06;
f3 := 20.*z+(e^(-x*y)+(-3.+10.*Pi)/3.

1)x=0.499999999686162; y=-6.029115021 10^-10; z=-0.523598775196563;
2)x=0.498144680773833; y=-0.199605897856040; z=-0.528825978056676
f1=-1 10^-9;
f2=1.0 10^-8;
f3=1 10^-8;
#79 Posted: 13 years ago
kilele

kilele

133 likes in 397 posts.

Group: User

@Alvaro

Do you think these methods based on bisection could be useful for non-linear systems ?
They don't need differentiability of function, and convergence is guaranteed.
This is a generalized bisection which could be used like HRE for initial root estimation:
https://dl.dropbox.com/u/3152568/A%20Rapid%20Generalized%20Method%20of%20Bisection%20for.pdf
This is a minimization algorithm based on bisection which is said to be an alternative to Nelder-Mead
https://dl.dropbox.com/u/3152568/A%20Multidimensional%20Bisection%20Method_E.Y.Morozova.pdf
1 users liked this post
Radovan Omorjan 13 years ago
#80 Posted: 13 years ago
Davide Carpi

Davide Carpi

1407 likes in 2870 posts.

Group: Moderator

Posted 

Epsilon and maxiters for bisection is redundant. Even it's more easy with maxiters, is better to take Epsilon (one for each axis, but that is not related with maxiters redundance). In the code maxiters is calculated as N. Actually, the main loop can be implemented with a for loop.

Regards.

Alvaro.



Ahhhh, previously I understood that you wanted to remove completely (in the function) the maxiter, not to replace it with the number of iterations provided... you're right, excuse me

BTW the plugin single equations solvers actually supports the 2nd Epsilon, but I have not yet updated the reference sheets.


regargds,

w3b5urf3r
If you like my plugins please consider a donation to SMath Studio; for personal contributions to me: paypal.me/dcprojects
  • New Posts New Posts
  • No New Posts No New Posts