NonlinearSolvers plugin

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

#121 Posted: 1/31/2013 10:15:37 PM
Davide Carpi

Davide Carpi

1417 likes in 2873 posts.

Group: Moderator

Wrote

Hello w3bsurf3r,

I played around with nonlinear solvers, unfortunately without any success. At least not if units are involved.

Are the solvers supposed to work with units?
- can the unknown variables have units (given via units of limits or start point)?
- need the epsilons have units as well?

do I need to define functions or can I just give expressions as first argument?



Are the solvers supposed to work with units? -> yes...
- can the unknown variables have units (given via units of limits or start point) -> yes...
- need the epsilons have units as well? -> yes, of course...

...but something is clearly broken, somewhere (here there is an example of applications with units)
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#122 Posted: 2/1/2013 5:32:14 AM
kilele

kilele

133 likes in 397 posts.

Group: User

Wrote


- need the epsilons have units as well?


rootsunits.png
2 users liked this post
Davide Carpi 2/1/2013 7:00:00 AM, Martin Kraska 2/1/2013 6:13:00 AM
#123 Posted: 2/1/2013 6:34:41 AM
Martin Kraska

Martin Kraska

1222 likes in 2150 posts.

Group: Moderator

Thanks, kilele, for the examples.

Indeed most of my problems were caused by my wrong assumption of epsilon being a tolerance to the unknown variable to be solved for. Obviously it is a tolerance to the function. I remember that we had a discussion on the subject if we should have tolerances to variables and function values and how to specify them. For now I shall assume that all implemented Solvers assume function tolerances.

The question of function vs. expression remains open.

Martin
Bisection test.png
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#124 Posted: 2/1/2013 7:04:25 AM
Martin Kraska

Martin Kraska

1222 likes in 2150 posts.

Group: Moderator

Hello w3bsurf3r,

Wrote



Are the solvers supposed to work with units? -> yes...
- can the unknown variables have units (given via units of limits or start point) -> yes...
- need the epsilons have units as well? -> yes, of course...



Thanks for clarifying, now I made some progress.
I still fail to specify systems of equations correctly. Any idea what is wrong?

I like the feature of the roots() function that you can specify an equation with RHS and LHS. As I understand the solvers in the plugin do not allow that type of specification. Ok, it is allowed but then the solution is any set of unknowns that render the equations unsatisfied (boolean equal giving 0).

Would that be difficult to implement (perhaps by internal transformation to standard form)?
AS 7-7Bisection.sm (99 KiB) downloaded 102 time(s).
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#125 Posted: 2/1/2013 8:06:43 AM
Martin Kraska

Martin Kraska

1222 likes in 2150 posts.

Group: Moderator

The Bisection test file in the plugin docs is outdated (examples have the now removed iterations argument). I attached a corrected version.

Martin
Bisections_testing.sm (29 KiB) downloaded 102 time(s).
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
1 users liked this post
Davide Carpi 2/1/2013 12:14:00 PM
#126 Posted: 2/1/2013 12:11:49 PM
Davide Carpi

Davide Carpi

1417 likes in 2873 posts.

Group: Moderator

Wrote

Thanks for clarifying, now I made some progress.
I still fail to specify systems of equations correctly. Any idea what is wrong?

I like the feature of the roots() function that you can specify an equation with RHS and LHS. As I understand the solvers in the plugin do not allow that type of specification. Ok, it is allowed but then the solution is any set of unknowns that render the equations unsatisfied (boolean equal giving 0).

Would that be difficult to implement (perhaps by internal transformation to standard form)?


I think the issue involving the massive solver it's something related with multiple convergence criterions; I need to investigate...

As a general rule, input bounds (or initial guess) have the same unit of unknown; so if you use a dimensionless unknown, you must input dimensionless bounds. What's the unknown, x or D? Basically D=f(x) it's a parametric variable, so the parameter (x) it's the unknown. Look the symbolic evaluation of your input function to check this (see the attachments).

The RHS/LHS function was in my goals from the beginning; working with DataExchange export features I've understand how to do it, will be implemented ASAP... Unfortunately, the code of the plugin is currently as a Dr. Frankenstein creature, so it will take some time to restore the order and then introduce new features.

Wrote

The Bisection test file in the plugin docs is outdated (examples have the now removed iterations argument). I attached a corrected version.

Martin


Thank you very much :d


best regards,

w3b5urf3r
AS%207-7Bisection.sm (107 KiB) downloaded 96 time(s).
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
1 users liked this post
Martin Kraska 2/1/2013 4:09:00 PM
#127 Posted: 2/1/2013 4:07:48 PM
Martin Kraska

Martin Kraska

1222 likes in 2150 posts.

Group: Moderator

Hello w3bsurf3r,

thanks again for the help. Now I can take advantage of the unit capabilities of your plugin at least for scalar equations. That already renders the solution of my example quite lean. No need for dimensionless variables any more.

Martin


AS 7-7Bisection_skalar.png
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#128 Posted: 2/7/2013 12:53:10 PM
Martin Kraska

Martin Kraska

1222 likes in 2150 posts.

Group: Moderator

Hello w3bsurf3r,

I am again running into problems with equation solving. I never can exclude wrong operation but these seem like bugs.

Broyden and HRE.B do not handle zero starting values

Brent fails to solve a linear equation.

Martin
AS 3-26 solvers.sm (200 KiB) downloaded 102 time(s).
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#129 Posted: 2/7/2013 1:22:45 PM
Davide Carpi

Davide Carpi

1417 likes in 2873 posts.

Group: Moderator

Wrote

Hello w3bsurf3r,

I am again running into problems with equation solving. I never can exclude wrong operation but these seem like bugs.

Broyden and HRE.B do not handle zero starting values

Brent fails to solve a linear equation.

Martin


Hi Martin,

Yes, Broyden can't be solved with units if you use a null initial guess... In SMath Studio the 0 value have no units by default, I've already mentioned this behavior writing the first UoM() snippet function (I'm not sure if this is related to some SMath feature or it's a simple lack).
I can improve the function looking for units inside the 2nd error parameter (if any), but nothing more... As for now you can use a small number (f.e. 10^{-15}*'mm)

About Brent I see an "Units don't match" error, I need to investigate...


Thanks again for your testings

w3b5urf3r
SMath Studio - [AS 3-26 solvers.sm].png
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#130 Posted: 2/7/2013 6:40:19 PM
Martin Kraska

Martin Kraska

1222 likes in 2150 posts.

Group: Moderator

Wrote


Yes, Broyden can't be solved with units if you use a null initial guess... In SMath Studio the 0 value have no units by default, I've already mentioned this behavior writing the first UoM() snippet function (I'm not sure if this is related to some SMath feature or it's a simple lack).



Hi w3bsurf3r

wondering why this problem obviously does not affect Newton Raphson, I came to the conclusion

The unit of measurement of the unknown can be obtained by dividing the unit of measurement of the function at x=0 by the gradient at that point. This works as long as
  • the gradient wrt the unknowns can be generated symbolically
  • the gradient is defined and nonzero at x=0

In fact, nothing else than dividing f by it's gradient is done by NR, such that the mentioned conditions should be more or less also the conditions for applicability of NR.

Martin
Gradient.PNG
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#131 Posted: 2/8/2013 6:56:55 AM
Davide Carpi

Davide Carpi

1417 likes in 2873 posts.

Group: Moderator

Wrote

Hi w3bsurf3r

wondering why this problem obviously does not affect Newton Raphson, I came to the conclusion

The unit of measurement of the unknown can be obtained by dividing the unit of measurement of the function at x=0 by the gradient at that point. This works as long as

  • the gradient wrt the unknowns can be generated symbolically
  • the gradient is defined and nonzero at x=0

In fact, nothing else than dividing f by it's gradient is done by NR, such that the mentioned conditions should be more or less also the conditions for applicability of NR.

Martin



You're absolutely right!

However (IMHO) the native units support for zero values in SMath would be very appreciable
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#132 Posted: 2/26/2013 10:27:53 AM
Davide Carpi

Davide Carpi

1417 likes in 2873 posts.

Group: Moderator

"The plotted course"

EDIT: previews

[albumimg]59[/albumimg][albumimg]58[/albumimg][ALBUMIMG]67[/ALBUMIMG]
[ALBUMIMG]68[/ALBUMIMG][ALBUMIMG]88[/ALBUMIMG][ALBUMIMG]111[/ALBUMIMG]
[ALBUMIMG]112[/ALBUMIMG]
SMath Studio - [NonlinearSolvers Working Plan.sm].png
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
1 users liked this post
Radovan Omorjan 2/26/2013 5:13:00 PM
#133 Posted: 2/27/2013 7:21:31 PM
Rising Eagle

Rising Eagle

15 likes in 23 posts.

Group: User

Wrote

can't be solved with units if you use a null initial guess... In SMath Studio the 0 value have no units by default, I've already mentioned this behavior writing the first UoM() snippet function (I'm not sure if this is related to some SMath feature or it's a simple lack).



In general, 0 is more than just a real number or place holder representing, in this case, an empty set. When it comes to systems with units, 0 is actually a chameleon with universal units (in the same way that type O blood is for universal donor). It can be handled by either treating each 0 as a function that transforms the number unitless 0 into a 0 with units of its surrounding factors as appropriate for the calculation, or by changing the rules of the uses of units as programmed into smath so that units associated with 0 (whether present or not) are completely ignored and all unit determinations are made by use of units provided by all non-0 factors.

#134 Posted: 3/4/2013 7:25:31 PM
Davide Carpi

Davide Carpi

1417 likes in 2873 posts.

Group: Moderator

Wrote

In general, 0 is more than just a real number or place holder representing, in this case, an empty set. When it comes to systems with units, 0 is actually a chameleon with universal units (in the same way that type O blood is for universal donor). It can be handled by either treating each 0 as a function that transforms the number unitless 0 into a 0 with units of its surrounding factors as appropriate for the calculation, or by changing the rules of the uses of units as programmed into smath so that units associated with 0 (whether present or not) are completely ignored and all unit determinations are made by use of units provided by all non-0 factors.


I agree with your logic

However I hope that in future the numeric optimization can preserve the units for zero values
SMath Studio - [Page1.sm]_2.png
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#135 Posted: 5/6/2013 12:39:19 PM
Martin Kraska

Martin Kraska

1222 likes in 2150 posts.

Group: Moderator

Is the plugin expected to work under 0.96? I get just errors in type conversion.

Davide, I saw your recent previews and assume that there is a new version on the way, thus this post may be irrelevant. If not, I am ready to provide details on the problems.
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#136 Posted: 5/6/2013 12:48:48 PM
Davide Carpi

Davide Carpi

1417 likes in 2873 posts.

Group: Moderator

Wrote

Is the plugin expected to work under 0.96? I get just errors in type conversion.

Davide, I saw your recent previews and assume that there is a new version on the way, thus this post may be irrelevant. If not, I am ready to provide details on the problems.



Yes, there's a new version on the way, but requires time

There are no irrelevant posts for me... could be that I have already solved the problem, as well as no; feel free to post any issue
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#137 Posted: 5/6/2013 12:55:24 PM
Martin Kraska

Martin Kraska

1222 likes in 2150 posts.

Group: Moderator

Don't know, where to start, perhaps first making sure I have the current version of the plugin. Can you confirm that 1.0.4657.20187 is current? I got it from the link in the wiki plugin page and re-installed it in the course of trouble-shooting today.

In the handbook I have screenshots, where the Bisection function has no precision argument. That does not seem to work now. And I must admit that I didn't keep track with which version that image was generated.
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#138 Posted: 5/6/2013 1:06:03 PM
Davide Carpi

Davide Carpi

1417 likes in 2873 posts.

Group: Moderator

Wrote

Don't know, where to start, perhaps first making sure I have the current version of the plugin. Can you confirm that 1.0.4657.20187 is current? I got it from the link in the wiki plugin page and re-installed it in the course of trouble-shooting today.

In the handbook I have screenshots, where the Bisection function has no precision argument. That does not seem to work now. And I must admit that I didn't keep track with which version that image was generated.


Ah, yes.... this is because the screenshot is made with the latest BETA version

Quote

- solver Bisection(...) revisited (the number of iterations is no longer required, as reported by adiaz) (previous BETA - no changes);





best regards,

w3b5urf3r
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#139 Posted: 5/6/2013 1:21:18 PM
Andrey Ivashov

Andrey Ivashov

2270 likes in 3734 posts.

Group: Super Administrator

Wrote

However (IMHO) the native units support for zero values in SMath would be very appreciable


I'm agree. Do you have an exact example (which requires no additional plug-ins) where I can see an issue?

Regards.
#140 Posted: 5/6/2013 4:15:17 PM
Martin Kraska

Martin Kraska

1222 likes in 2150 posts.

Group: Moderator

Wrote


Ah, yes.... this is because the screenshot is made with the latest BETA version



The issue was indeed in mixing plugin versions. Now everything is red-free and consistent with the handbook. I'd recommend to put all current material (beta and non-beta) to the topic starter posting. But never mind, I am now a bit more strict in archiving plugin distros (and just can cite uni: need more sleep...)

Martin
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
  • New Posts New Posts
  • No New Posts No New Posts