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

Error

 14 Pages123>»
 Previous Topic Next Topic
 Wanna join the discussion?! Login to your SMath Studio Forum forum account. New Registrations are disabled.
 omorr #2 Posted : 05 September 2012 10:42:17(UTC) Rank: AdministrationGroups: Registered, Advanced MemberJoined: 23/06/2009(UTC)Posts: 1,740Was thanked: 318 time(s) in 268 post(s) w3b5urf3r you are my hero rinks: Many things like this one would make me very happy ancing: Regards,RadovanP.S. Do not take me wrong please, I am very happy that you've made this plugin but I think that my "home made" function does not deserve to be the reference to this rather welcome and appreciated plugin. I hope that your updates would base this plugin to some more trustworthy source.Edited by user 05 September 2012 11:55:38(UTC)  | Reason: Not specified When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
 omorr #3 Posted : 05 September 2012 12:36:37(UTC) Rank: AdministrationGroups: Registered, Advanced MemberJoined: 23/06/2009(UTC)Posts: 1,740Was thanked: 318 time(s) in 268 post(s) Hello w3b5urf3r Rather surprised and excited with this sys() thing regarding Broyden() As I do not know how is this working yet, this is a minor observation at a first glance.It seems that the vector indices play main role here.Broyden(sys(el(x,1)-2*el(x,2)+5,el(x,1)+3*el(x,2)-1,2,1),sys(1,2,2,1),eps,maxiter)=mat(-2.6,1.2,2,1) Broyden(sys(el(a,1)-el(2*b,2)+5,el(c,1)+3*el(d,2)-1,2,1),sys(1,2,2,1),eps,maxiter)=mat(-2.6,1.2,2,1)Broyden(sys(el(a,1)-el(2*b,2)+el(e,1),el(c,1)+3*el(d,2)+el(f,1),2,1),sys(1,2,2,1),eps,maxiter)=mat(0,0,2,1)This might be a confusion because vectors a,b,c,d,e,f are not defined and there is still a result returned. You managed to avoid mentioning vector of unknowns like in the roots(), and I think that vector indices are crucial things here to distinguish between unknowns, not sure. Am I right? If that is the case, I thing that this should be taken care of in the case of different vectors elements with the same indices in order what to refer to as vector of unknowns.Best wishes,Radovan When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
 omorr #5 Posted : 05 September 2012 17:28:52(UTC) Rank: AdministrationGroups: Registered, Advanced MemberJoined: 23/06/2009(UTC)Posts: 1,740Was thanked: 318 time(s) in 268 post(s) Hello w3b5urf3r,Whatever you do regarding this plugin will be very welcome AFAIC I have just to mention in the case you based your plugin on my SMath function, that I made it from a simple code found somewhere on the Net (even do not remember where from). If you are interested to spare some more of your time, you could try to find yourself some better algorithm and make a plugin from it .Regards,Radovan When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
 omorr #6 Posted : 05 September 2012 21:38:49(UTC) Rank: AdministrationGroups: Registered, Advanced MemberJoined: 23/06/2009(UTC)Posts: 1,740Was thanked: 318 time(s) in 268 post(s) Hello w3b5urf3r,Here is a bit of testing the Broyden plugin. It is a clasical "driving crasy" situation with multiple solutions. It was mentioned by kilele in the link to the document http://en.smath.info/forum/yaf_postsm7678_solve---and-roots-----again.aspx#post7678Your plugin failed (if I did not do something wrong) but do not worry about it - it is a common situation. The problem is why "Can not calculate" error returned. I do not know. My function returned another solution than few Newton-Raphson iterations or roots(). I also used another software that uses some kind of broyden algorithm and here is the result - the same as roots() returnedCode:``````>function f(x):=[(x[1]+3)*(x[2]^3-7)+18,sin(x[2]*exp(x[1])-1)] >x0:=[-0.5,1.4] [ -0.5 1.4 ] >f(x0) [ 7.36 -0.150285529841 ] >res:=broyden("f",x0) [ 0 1 ] >f(res) [ 0 0 ]`````` Try, for instance to change the guess values (vector x0) from [-0.5,1.4] to [1,4].Here is the picture and the sm fileRegards,RadovanEdited by user 05 September 2012 21:41:29(UTC)  | Reason: Not specifiedFile Attachment(s): Broyden_testings-1.sm (54kb) downloaded 104 time(s).omorr attached the following image(s): When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
 kilele #7 Posted : 06 September 2012 02:10:18(UTC) Rank: Advanced MemberGroups: Registered Joined: 30/03/2011(UTC)Posts: 393Was thanked: 132 time(s) in 113 post(s) maybe a good approach would be combine homotopy + broyden ?or obtaining good approximations of roots with a generalized bisection method and then refine with broyden or other method, as explained at the conclusions of this document:( see the link "pdf download" )A Rapid Generalized Method of Bisection for Solving Systems of Non-linear Equations Feel free to explore that strategy, as for me I'll take it easy with a first plugin for a one dimension bisection Edited by user 06 September 2012 02:17:01(UTC)  | Reason: Not specified 1 user thanked kilele for this useful post. on 07/09/2012(UTC)
 kilele #9 Posted : 06 September 2012 13:09:47(UTC) Rank: Advanced MemberGroups: Registered Joined: 30/03/2011(UTC)Posts: 393Was thanked: 132 time(s) in 113 post(s) Originally Posted by: w3b5urf3r_reloaded Currently, the plugin follows almost exactly that function, but if anyone has a more efficient version of the algorithm could certainly be implemented. I've just read that this implementation is better for large problems (see pag 133 of this pdf) and this is its matlab code@RadovanAs for making use of third part libraries on SMath, I don't know if that is possible aside from license issues 1 user thanked kilele for this useful post. on 07/09/2012(UTC)
 Davide Carpi #11 Posted : 06 September 2012 16:09:21(UTC) Rank: Advanced MemberGroups: Registered, Advanced MemberJoined: 13/01/2012(UTC)Posts: 2,674Location: ItalyWas thanked: 1354 time(s) in 888 post(s) Plugin updated, many issues fixed and bisection (not generalized) implemented...an optional argument at the end of the function arguments, different from 0, can show you the number of iterations...Originally Posted by: omorr Hello w3b5urf3r,Here is a bit of testing the Broyden plugin. It is a clasical "driving crasy" situation with multiple solutions. It was mentioned by kilele in the link to the document http://en.smath.info/forum/yaf_postsm7678_solve---and-roots-----again.aspx#post7678Your plugin failed (if I did not do something wrong) but do not worry about it - it is a common situation. The problem is why "Can not calculate" error returned. I do not know. My function returned another solution than few Newton-Raphson iterations or roots(). I also used another software that uses some kind of broyden algorithm and here is the result - the same as roots() returnedCode:``````>function f(x):=[(x[1]+3)*(x[2]^3-7)+18,sin(x[2]*exp(x[1])-1)] >x0:=[-0.5,1.4] [ -0.5 1.4 ] >f(x0) [ 7.36 -0.150285529841 ] >res:=broyden("f",x0) [ 0 1 ] >f(res) [ 0 0 ]`````` Try, for instance to change the guess values (vector x0) from [-0.5,1.4] to [1,4].Here is the picture and the sm fileRegards,RadovanThe function as in the *.sm file doesn't work because the first approximated inverse jacobian ( B ) is an Identity matrix... i've seen that is a common issue (f.e. root finding methods)... in SMath this could be fixed using the Jacob() function on the user input solution (see the attachment).Unfortunately the function Jacob() (as well as other functions such as error() function) are not in the 4 standard libraries; I will try to see if importing the library on which it was made ​​by Andrey can be implemented.Originally Posted by: kilele Originally Posted by: w3b5urf3r_reloaded Currently, the plugin follows almost exactly that function, but if anyone has a more efficient version of the algorithm could certainly be implemented. I've just read that this implementation is better for large problems (see pag 133 of this pdf) and this is its matlab code@RadovanAs for making use of third part libraries on SMath, I don't know if that is possible aside from license issues Thank you, is very useful; i've implemented this script in a Smath sheet and it's more readable, unfortunately the issue related to the first Jacob approximation still remains regards,w3b5urf3rEdited by user 06 September 2012 16:48:47(UTC)  | Reason: Not specifiedFile Attachment(s): Broyden_testings-2.sm (48kb) downloaded 94 time(s).Davide Carpi attached the following image(s): If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects 1 user thanked Davide Carpi for this useful post. on 06/09/2012(UTC)
 omorr #12 Posted : 06 September 2012 18:53:05(UTC) Rank: AdministrationGroups: Registered, Advanced MemberJoined: 23/06/2009(UTC)Posts: 1,740Was thanked: 318 time(s) in 268 post(s) Hello w3b5urf3r,Just keep up this way I would suggest you to strictly avoid using Jacob() inside Broyden - it will get new troubles. I really do not know what to use instead as a first Jacobian approximation. If someone have any idea, please help.When you have the time, put some examples using Bisection() as well in the next update.If I understood you well, you are trying to use Broyden with units (Dimensional analysis check failed...). Am I right? My suggestion is to skip this as well at the moment.Best wishes,RadovanEdited by user 06 September 2012 18:54:57(UTC)  | Reason: Not specified When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
 kilele #13 Posted : 06 September 2012 21:59:50(UTC) Rank: Advanced MemberGroups: Registered Joined: 30/03/2011(UTC)Posts: 393Was thanked: 132 time(s) in 113 post(s) wow, have you used bisection as an initialization of broyden ?also i've searched information about the broyden method over time and it seems the most advanced/recent version is a modification of Johnson's by Baran :http://arxiv.org/abs/0805.4446 As for the Jacob() function, I thought that Broyden didn't use Jacob directly but an approximation..EDIT:Never mind, the above paper refers to a gpl program based on other libraries.There you have the historial of Broyden method,http://www.unedf.org/con.../Day2/PackForest_JJM.pdfit seems to me that the "compact" version of 1994 corresponds to the matlab code that I linked above.Edited by user 06 September 2012 22:17:09(UTC)  | Reason: Not specified 2 users thanked kilele for this useful post. on 07/09/2012(UTC),  on 07/09/2012(UTC)
 kilele #15 Posted : 07 September 2012 03:01:45(UTC) Rank: Advanced MemberGroups: Registered Joined: 30/03/2011(UTC)Posts: 393Was thanked: 132 time(s) in 113 post(s) Another matlab code to reduce memory requirements on this quite recent pdf pag.211 Appendix BThanks for your work!!Edit: Again since Broyden is not globally convergent, bisection might be interesting as an initial approaching to the rootsEdited by user 07 September 2012 03:16:27(UTC)  | Reason: Not specified 1 user thanked kilele for this useful post. on 07/09/2012(UTC)
 kilele #16 Posted : 07 September 2012 13:22:44(UTC) Rank: Advanced MemberGroups: Registered Joined: 30/03/2011(UTC)Posts: 393Was thanked: 132 time(s) in 113 post(s) Originally Posted by: omorr I was thinking about the freely available libraries, open source software etc. I do not see then any license problems (am I right?) except the ones I was talking about.since SMath is not a commercial software i guess we can be not too strict about licenses anyway some licenses like gpl don't allow to publish opensource plugins for closed programs (unlike lgpl)as for distributing compiled matlab scripts, I think you are right! see this linkdon't know how this black boxes could be used in SMAth though, however the approach of making plugins out of matlab, fortran, pseudo-code from scientific papers.. could be more convenient due to compatibility and dll size 1 user thanked kilele for this useful post. on 07/09/2012(UTC)
 omorr #17 Posted : 07 September 2012 16:21:25(UTC) Rank: AdministrationGroups: Registered, Advanced MemberJoined: 23/06/2009(UTC)Posts: 1,740Was thanked: 318 time(s) in 268 post(s) Hello, This is one of my working problems I was already mentioned Primer 65a and struggled in SMath with. I reported there the problems of solve() and roots() solutions.I used it again for testing and attached it to this post. It seems the problem is a bit numerically "tricky" for solving in SMath. The original file is not working in the recent SMath version, neither solve() nor roots() (error message about T as undefined variable - not quite sure why). Here I attached the revised file - just removed eval() I was talking about in the previous post. Fortunately, solve() will now get the more accepted result , roots() will fail, Broyden() will give the answer if the guess value is quite close to the solution, Bisection() will fail as well. I hope I did not make any serious mistake here.Regarding this problem, I am satisfied that at least one of the possible tool in SMath can give the result.Regards,RadovanEdited by user 07 September 2012 16:29:03(UTC)  | Reason: Not specifiedFile Attachment(s): Primer65aa.sm (42kb) downloaded 75 time(s).omorr attached the following image(s): When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
 kilele #18 Posted : 07 September 2012 19:18:39(UTC) Rank: Advanced MemberGroups: Registered Joined: 30/03/2011(UTC)Posts: 393Was thanked: 132 time(s) in 113 post(s) According to what I've read, there seems not to be robust methods in multidimensions:Without insight into the nature of the problem, root finding is more or less blind search, this is why I suggested a multidimensional bisection method for a initial guess with just a few iterations.With some insight into the nature of the root, Newton’s method using derivative information, and Broyden’s method using only function information seem good candidates.Some information about methods followed by Octave:fsolve in Octave implements the multidimensional Newton methodfzero in Octave uses Brent’s method for one dimension (bisection+secant)All these info is nearly copy-pasted of this doc I think also that there are some interesting advice on this pdf on page 20:Final Considerations, about how to rephrase your function so that all these algorithms work better.As a final suggestion (sorry for so many links to documents) it could be a good idea to make plugins for several methods: Brent (one dimension); Newton, Broyden and Homotopy methods (multidimension); and It could be even better combine some of these methods in a row or according to the type of function entered by the user (I assume that's how Smath Solve() works)Edited by user 07 September 2012 20:30:37(UTC)  | Reason: Not specified 1 user thanked kilele for this useful post. on 07/09/2012(UTC)
 Davide Carpi #19 Posted : 07 September 2012 20:08:33(UTC) Rank: Advanced MemberGroups: Registered, Advanced MemberJoined: 13/01/2012(UTC)Posts: 2,674Location: ItalyWas thanked: 1354 time(s) in 888 post(s) Originally Posted by: omorr Hello, This is one of my working problems I was already mentioned Primer 65a and struggled in SMath with. I reported there the problems of solve() and roots() solutions.I used it again for testing and attached it to this post. It seems the problem is a bit numerically "tricky" for solving in SMath. The original file is not working in the recent SMath version, neither solve() nor roots() (error message about T as undefined variable - not quite sure why). Here I attached the revised file - just removed eval() I was talking about in the previous post. Fortunately, solve() will now get the more accepted result , roots() will fail, Broyden() will give the answer if the guess value is quite close to the solution, Bisection() will fail as well. I hope I did not make any serious mistake here.Regarding this problem, I am satisfied that at least one of the possible tool in SMath can give the result.Regards,RadovanI omorr, i'll check this issue ASAP, especially because in this case the script seems to work while the plugin don't work...about eval(), you cannot use it where there are undefined variables because the function "force" the numeric evaluation.best regards,w3b5urf3rEdited by user 18 September 2012 01:29:23(UTC)  | Reason: Not specifiedDavide Carpi attached the following image(s): If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects 1 user thanked Davide Carpi for this useful post. on 07/09/2012(UTC)
 omorr #20 Posted : 07 September 2012 22:05:00(UTC) Rank: AdministrationGroups: Registered, Advanced MemberJoined: 23/06/2009(UTC)Posts: 1,740Was thanked: 318 time(s) in 268 post(s) Originally Posted by: kilele As a final suggestion (sorry for so many links to documents) it could be a good idea to make plugins for several methods: Brent (one dimension); Newton, Broyden and Homotopy methods (multidimension); and It could be even better combine some of these methods in a row or according to the type of function entered by the user (I assume that's how Smath Solve() works)I agree with you completely 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. @w3b5urf3r Based on the picture in your previous post (many methods in a plugin), did I say that you are my hero? Regards,RadovanEdited by user 07 September 2012 22:15:32(UTC)  | Reason: Not specified When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!" 1 user thanked omorr for this useful post. on 08/09/2012(UTC)
 Users browsing this topic
 14 Pages123>»
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.