fsolve() crash with given Interval

06052014, 01:24 PM
Post: #1




fsolve() crash with given Interval
The example for fsolve given in the help sytem is
fsolve([x^2+y2 x+y^22],[x y],[0 0]) and solves to [1. 1.]. However if I change the guesses into intervals both, prime and emulator crash. No error message nor result. Should fsolve work with intervals for 2 variable expressions or is there something wrong with that? The expression causing the crash is fsolve([x^2+y2 x+y^22],[x y],[1..1 1..1]) 

06052014, 03:36 PM
Post: #2




RE: fsolve() crash with given Interval
Intervals are allowed only in 1 dimension, where you can do bisection. It does not work in larger dimension since bisection does not. Of course it should not crash and up to date versions of giac return an error.


06052014, 04:44 PM
(This post was last modified: 06052014 04:58 PM by alexzkter.)
Post: #3




RE: fsolve() crash with given Interval
(06052014 03:36 PM)parisse Wrote: Intervals are allowed only in 1 dimension, where you can do bisection. It does not work in larger dimension since bisection does not. Of course it should not crash and up to date versions of giac return an error. What to do when the unknowns x and y are inside cos & sin functions ? I only want to get values between 0360 degrees, not values higher than that. My system is: Quote:0.84=0.3912*cos(x)+0.3824*cos(y)+0.3606*cos(225) The solution should be x=11.31º and y=302.47º 

06052014, 05:44 PM
(This post was last modified: 06052014 05:45 PM by Angus.)
Post: #4




RE: fsolve() crash with given Interval
Thank you. Makes sense I must admit. Is it possible to update help texts about such things? It was not aware of that when playing with the help system. I am sure there are more limitations somewhere.
I'll try the sin cos example this evening. 

06052014, 06:37 PM
(This post was last modified: 06052014 06:38 PM by parisse.)
Post: #5




RE: fsolve() crash with given Interval
In radians your system becomes:
Code: eq:=[0.84=0.3912*cos(x)+0.3824*cos(y)+0.3606*cos(225/180*pi),0=0.3912*sin(x)+0.3824*sin(y)+0.3606*sin(225/180*pi)] Code: implicitplot(eq[0],[x=0.4..5,y=0.4..5]);implicitplot(eq[1],[x=0.4..5,y=0.4..5],color=red) It seems there are 2 intersection points in [0,2*pi]x[0,2*pi], Code: fsolve(eq,[x,y],[2.1,3.2]); fsolve(eq,[x,y],[3.2,2.1]) Approx solutions here [2.13760652067,3.33911049122] and [3.32352103537,2.12201706482]. This particular system could probably be solved by eliminating one variable using sin^2+cos^2=1. 

06052014, 07:58 PM
Post: #6




RE: fsolve() crash with given Interval
Parisse  thanks for the information on implicitplot though Im having trouble getting it to work in Geometry app. Studying plotimplicit in online help..
It does seem handy in these 2 dimension non linear equation sets, to first plot them in Adv Grapher to see where solution(s) exist. I attached one. Let that guide initial guesses for fsolve(). Unfortunately, its not clear to me how to easily send the equations to/from Advanced_Graphing.V1 <> CAS, especially when they want X, x respectively. 

06052014, 08:39 PM
(This post was last modified: 06052014 08:52 PM by Angus.)
Post: #7




RE: fsolve() crash with given Interval
It's interessting to see that eq[1] is translated to at(eq,0)... I do prefer zero based indices. Most people from the c/c++ world will do.
Interessting both ways seem to be mixed up in the prime? That could be fixed aswell (just to point to some inconsistancies, again) edit: CR Haeger's question is something I do, too have not understood. What workflow on things like this did you guys at HP have had in mind in the design stage of development? I think the fixed named variables trick me... 

06062014, 05:56 AM
Post: #8




RE: fsolve() crash with given Interval
Sorry, I tried on Xcas. I forgot that on the Prime, HP decided to remove many synonyms, therefore implicitplot is not avail on the Prime. And also indices start at 0 on Xcas, and 1 on the Prime, so you must shift by 1 (on the first firmware, [] indices started at 0 in CAS, but this was confusing because they start at 1 otherwise with ()).
And you can't replace x by X and y by Y with subst because X and Y are evaled. Perhaps you can define a CAS function of 2 variables and pass it with X and Y in the advanced grapher? By the way, it shows all the limitations of the 38like HOME screen, as soon as you want to do something that was not anticipated by the developpers. 

06062014, 06:34 AM
Post: #9




RE: fsolve() crash with given Interval
Hello Bernard,
wouldn't the CAS be much easier to be used if the evaluation to a numerical value is carried only if excplicitly called by a user? See my old post for a suggestion how to implement it: CAS and evaluation of variables Regards Bernd Grubert 

06062014, 07:25 AM
(This post was last modified: 06062014 07:28 AM by parisse.)
Post: #10




RE: fsolve() crash with given Interval
I have never seen a CAS where you must make an explicit call to replace a variable by the assigned value. Because you will want to store equations, expressions, functions and you don't want to enter something like eval(f)(eval(x0),eval(y0)).
But there is a mechanism in Xcas that allows keeping the symbolic value if evaluation is exact and replacing by the numeric value if evaluation is approx (evalf), it's a slider. Try assume(a=[0,5,5,0.1]), then factor(a^21) and a^21.0. I did not try it on the Prime, I guess it should work, but you will not be able to change the numeric value of the slider interactively like in Xcas. 

06062014, 07:59 AM
(This post was last modified: 06062014 08:03 AM by Angus.)
Post: #11




RE: fsolve() crash with given Interval
I am sure the designers thought of the wish to pass any cas object to the apps. Working inside the apps is ok for demonstration purposes and for doing exercises, but when using the device in practice you soon get to a point where expressions not only depend on x and y.
There is much I criticise, but about this I cannot believe the things did not come up. Would it be an Option that in the apps each equation uses variables like x any y but they can be changed in the dialog or by the plot commands? Using my emulator the indices and the calling mechanism is modified by the calc. You don't Even See the 1 based index in the History in the above example. 

06062014, 08:08 AM
(This post was last modified: 06062014 08:10 AM by parisse.)
Post: #12




RE: fsolve() crash with given Interval
I have a suggestion: what about translating lowercase 1letter variable names to uppercase 1letter variable names when doing Menu>Get from CAS? If you leave them lowercase, you get an error anyway. I think this would ease the transfert from CAS expressions to the Apps and we could have the best of both worlds!
By the way sliders work on the Prime (except that they are not interactive, in Xcas you can move the slider with the mouse and all computations after the slider are recomputed). 

06062014, 08:12 AM
Post: #13




RE: fsolve() crash with given Interval
Commands like plotimplicit still require x and y for independant var. If I transfer some expression of a,b that would not help, would it?


06062014, 08:13 AM
Post: #14




RE: fsolve() crash with given Interval
(06062014 07:25 AM)parisse Wrote: I have never seen a CAS where you must make an explicit call to replace a variable by the assigned value.You're right, this is unusual, but the HP Prime is also unsual in handling vars compared to the HP 50G, since all vars are in global scope. On the HP 50G I could create variables with numerical values in a directory down the directory tree. I when I wanted to do symbolic manipulations of an expression I just moved a directory upwards. (06062014 07:25 AM)parisse Wrote: Because you will want to store equations, expressions, functions and you don't want to enter something like eval(f)(eval(x0),eval(y0)).I don't this that this is necessary. I think a simple eval(f(x0,y0)) should be sufficient. One could even create a softmenu entry in the CAS for numerical evaluation (like the simplify button). To me the advantages are huge. I can copy an expression from the solver or function APP manipulate it in the CAS and copy it back into the function APP without having to do cumbersome substitions. 

06062014, 08:48 AM
Post: #15




RE: fsolve() crash with given Interval  
06062014, 08:51 AM
Post: #16




RE: fsolve() crash with given Interval
(06062014 08:13 AM)Bernd Grubert Wrote: You're right, this is unusual, but the HP Prime is also unsual in handling vars compared to the HP 50G, since all vars are in global scope. On the HP 50G I could create variables with numerical values in a directory down the directory tree. I when I wanted to do symbolic manipulations of an expression I just moved a directory upwards.I don't want to change the evaluation mechanism just for the Prime, and even if I wanted to, I'm certain it would have many sideeffects (understand lot of new bugs!). You can use assume as explained above. 

06062014, 11:14 AM
Post: #17




RE: fsolve() crash with given Interval
(06062014 08:51 AM)parisse Wrote: You can use assume as explained above. Assume doesn't help, since I my issue is the other way around. I have assigned a value to e.g. a variable called lamdba somewhere in an app and want to do some symbolic calculations in CAS without evaluation. (06062014 08:51 AM)parisse Wrote: I don't want to change the evaluation mechanism just for the Prime, and even if I wanted to, I'm certain it would have many sideeffects (understand lot of new bugs!). I understand your point. I don't know whether applications like the geometry app implicitly rely on CAS evaluation. If this is the case, then there sure will be side effects. Otherwise I still am of mind that this should be feasible. 

06062014, 11:22 AM
Post: #18




RE: fsolve() crash with given Interval
(06052014 06:37 PM)parisse Wrote: Approx solutions here [2.13760652067,3.33911049122] and [3.32352103537,2.12201706482]. 2.13 and 3.33 radians are the answers to my system? That's 122º and 190º if I'm not mistaken, which are not the answers I was looking for :/ 

06062014, 11:23 AM
(This post was last modified: 06062014 11:33 AM by Angus.)
Post: #19




RE: fsolve() crash with given Interval
Quote:You can use any independent var for plotimplicit, you just need to pass them as arguments in order to replace the default x,y. Are you sure about that? The online help describes plotimplicit as Quote:... Plots an implicitly defined curved from Expr(in x and y). Specifically, plots Expr=0. Note the use of lowercase x and y. With the optional xinterval and yinterval, plots only within those intervals.... It says nothing about other independents. Maybe HP treated the apps independantly from the rest of the system instead of considering the whole package?  I find myself struggling with this topic of interaction of data on a regular basis. Is plotimplicit part of the cas or the app? If cas than it seems the commands differs from xcas? edit: eq:=a^2+2*b plotimplicit(eq,a,b) works executed in the cas. but typing in adv graphing gives syntax error. geometry seems to work. 

06062014, 01:05 PM
Post: #20




RE: fsolve() crash with given Interval
(06062014 11:14 AM)Bernd Grubert Wrote: Assume doesn't help, since I my issue is the other way around. I have assigned a value to e.g. a variable called lamdba somewhere in an app and want to do some symbolic calculations in CAS without evaluation.If it's in geometry, then it might work, since this syntax of assume was created at the beginning for Xcas interactive geometry, to be able to make proofs while displaying something. Quote:I understand your point. I don't know whether applications like the geometry app implicitly rely on CAS evaluation. If this is the case, then there sure will be side effects. Otherwise I still am of mind that this should be feasible.I don't think it's that simple, because the whole system is built with the idea that arguments are evaled. As for the apps, geometry is a CAS app, the others apps are independant of the CAS. 

« Next Oldest  Next Newest »

User(s) browsing this thread: 1 Guest(s)