25MAR2017 SolveSys  Equation Library and Nonlinear Systems Solver

02162017, 02:25 AM
Post: #21




RE: SolveSys  Equation Library and Multiple Equations Solver
(02152017 10:41 PM)akmon Wrote: Ok, this is another thing. It solves correctly. It´s curious that if I insert R=8, the program founds a zero, but if I input R=9 it says "Bad guess", however the result is correct. The clue is F value. If it is very low you can assume that the solution is quite correct. I´ll make more tests. Well, now that is indeed curious. This system is as smooth as a system can get, with plenty of variation  so there would be no concern about insufficient decreases in the minimization function \( f \). Quote:By the way, this equation was pending of answer. I´ve read that the app allows to insert complex equations, I tried this: (2+i)*X+2*Y=1+7*i ; (1i)*X+i*Y=0 but I get a syntax error, don´t know to input the i value. X and Y are builtin system variables  and by design, they only allow real values, not complex values. The syntax error was enforced to maintain this rule. So if you want to use complex variables, either use Z0 through Z9, or create your own variable (which does not have any restriction). (The solver will still solve for the variables  and even produce complex results  since it also keeps a copy of those values internally but you will not be able to simply type X or Y to get them. And you will be limited to realvalued guesses.) Graph 3D  QPI  SolveSys 

02162017, 02:46 AM
(This post was last modified: 02162017 04:35 AM by Han.)
Post: #22




RE: SolveSys  Equation Library and Multiple Equations Solver
So I found the issue  it was in the line search. There was a missing line of code in the cubic approximation of function \( g(\lambda) = f(\mathbf{x} + \lambda \cdot \mathbf{\Delta x}) \) (as referenced in Numerical Recipes, Art of Scientific Computing). This lead to "bad guesses" when the guess was actually just fine. In fact, your earlier post with A=2 and B=1 tested out just fine with the correction. I had too quickly dismissed this guess as a bad guess because of the nature of the system (not smooth) and because the solutions were so tiny (I just dismissed the issue as a precision issue).
There is, however, a division by 0 problem. Some of the "tricks" used to reduce the number of calculations ended up costing me numerical stability. For example, \(f + f_\text{old} \cdot (2\lambda 1) \) is 0 when \( f \), \( f_\text{old} \), and \( \lambda \) are all very tiny. On the other hand, \( f  f_\text{old} + 2 \cdot \lambda \cdot f_\text{old} \) preserves many more significant digits even if \( \lambda\) is significantly smaller than \( f \) or \( f_\text{old} \). The former sometimes leads to division by 0 whereas the latter keeps us slightly safer. Thank you for your dedication to testing the program. It is always nice to have extra sets of eyes checking to make sure all is in good order. Updates to be posted soon. PS: I forgot to mention this, but I put in a number of debugging snippets of code to help with the testing. If you need to see the messages that are output during the solving portion, use: BLIT_P(G1); FREEZE; WAIT(1); I keep a copy in G1 for this specific purpose. This way you can always see the most recent messages just before the program ends in any unexpected way. Graph 3D  QPI  SolveSys 

02162017, 11:05 PM
Post: #23




RE: SolveSys  Equation Library and Multiple Equations Solver
It´s a pleasure testing this kind of programs, so important for having on a HP. One of my "hall of fame" programs.
Complex system solved, using Z0, Z1 variables, sweet. I have tested other difficult examples and works flawlessly. Tomorrow more. 

02192017, 02:45 PM
(This post was last modified: 02192017 10:24 PM by akmon.)
Post: #24




RE: SolveSys  Equation Library and Multiple Equations Solver
It happened somethig weird. Tried to solve 1D Elastic Collisions, two equations, fixed m1=1, m2=2, v1i=3 and v1f and v2f as variables to solve. But When I press Ok, it returns to the equations page.CMD line shows "Populating equations in Symb view".
But here is the curiosity. I tried several times pressing OK and [NUM], about 8 times, and guess what, it found a zero!!. And the rest of the times, I change the initial guesses and it solves it flawlessly. EDit: same behaviour in other systems of equation library. But this time I cannot solve it, always return to equation menu, no matter what guess I input in the vars pending of solving. What could has happened? 

02192017, 11:25 PM
(This post was last modified: 02202017 04:08 AM by Han.)
Post: #25




RE: SolveSys  Equation Library and Multiple Equations Solver
(02192017 02:45 PM)akmon Wrote: It happened somethig weird. Tried to solve 1D Elastic Collisions, two equations, fixed m1=1, m2=2, v1i=3 and v1f and v2f as variables to solve. But When I press Ok, it returns to the equations page.CMD line shows "Populating equations in Symb view". EDIT: Regarding the bold within the quote  please let me know which system had thes symptoms. You found a bug in the library file. The system was defined with the variable v2i which does not exist in the system. If you want, you can edit the original file to remove the v2i reference. It should look like: Code: { Basically, delete the v2i variable in the fourth list, its description in the fifth list, and remove one of the 0's in both the sixth and seventh lists. You may need to use the utilities I posted earlier to convert the library into a Note file for ease of editing. EDIT: There is probably another bug in the sweep routine; but the fact that you eventually could solve it suggest that the autodeletion algorithm is working for abandoned variables. Graph 3D  QPI  SolveSys 

02202017, 07:55 AM
Post: #26




RE: SolveSys  Equation Library and Multiple Equations Solver
Quote:EDIT: Regarding the bold within the quote  please let me know which system had thes symptoms. Forces and Energy Linear Mechanics I select 3 equations: Ki=1/2*m*vi^2, Kf=1/2*m*vf^2 and W=KfKi I insert m=2, vi=5 and vf=8 as constants. So we have 3 variables to solve in 3 equations. It always return to equation menu. I use several guess values, but the result is always the same. 

02202017, 12:35 PM
(This post was last modified: 02202017 03:37 PM by Han.)
Post: #27




RE: SolveSys  Equation Library and Multiple Equations Solver
EDIT: New uploads in first post
(02202017 07:55 AM)akmon Wrote:Quote:EDIT: Regarding the bold within the quote  please let me know which system had thes symptoms. It looks like when selecting fewer equations than the entire system, the posted version did not properly store the initial values. I made a recent change that likely fixed the issue. In the ssVarBrowswer() function, toward its end, there is a 'p' that should be a 'j'. The only reference to p should be vals(p) and everything else should be referencing j. Code: if j then Graph 3D  QPI  SolveSys 

02202017, 05:38 PM
Post: #28




RE: 20FEB2017 SolveSys  Equation Library and Multiple Equations Solver
Cool, a huge advance. And now the complete library!!. Previous equation problems sorted, tried a few examples and it works fantastic.
But there is something strange in Stress analisys Mohr´s circle. The [NUM] menu of variables does not work, it remains in equation menu with two empty fields between equations. 

02202017, 06:51 PM
(This post was last modified: 02212017 12:44 AM by Han.)
Post: #29




RE: 20FEB2017 SolveSys  Equation Library and Multiple Equations Solver
Dang it  I forgot to account for HAngle being a system variable.
EDIT: The current workaround is to simply modify the formula to use 90 as the angle (or whichever you prefer) and make sure that you set your angle mode to the correct one when solving. After modifying the formulas in the [Symb] view, you can save the update using the [View] menu. I will have to figure something out for the system variables such as this one. This occurs in the Stress Analysis category of systems, and Brewster's Law (Optics). EDIT2: Ideal Gas Law variables list is missing "m" for "Mass"; "Pi" cannot be used for initial pressure since it conflicts with key word "PI" (3.142...) in Ideal Gas State Change Graph 3D  QPI  SolveSys 

02212017, 01:11 AM
(This post was last modified: 02242017 02:41 AM by Han.)
Post: #30




RE: 20FEB2017 SolveSys  Equation Library and Multiple Equations Solver
Updated 9:40PM EST 23FEB2017  redownload using the same link
Here's a slight update to the app file "Equation Library.lib"  copy the list below and (in the virtual calc) type: AFiles("Equation Library.lib"):= <insert list below> eqlib.lib.txt (Size: 45.3 KB / Downloads: 57) Graph 3D  QPI  SolveSys 

02232017, 10:05 PM
Post: #31




RE: 20FEB2017 SolveSys  Equation Library and Multiple Equations Solver
Great evolution of this project.
Thx Han 

02232017, 11:46 PM
Post: #32




RE: 20FEB2017 SolveSys  Equation Library and Multiple Equations Solver
The program is solving smoother as versions upgrades. I´ve made a quick review to the equation library, and here are the flaws I detected, to confirm with your opinion:
Electricity Systems 3, 4, 6, 7 and E. Conflicts with variables, can´t solve values, return to equation menu. Fluids System 2 conflict with D1 and D2 variables, but is able to solve. Gases System 2 conflict with V0 but is able to solve. Motion system 3. Cannot get into [NUM] menu, 

02242017, 01:59 AM
(This post was last modified: 02242017 04:21 PM by Han.)
Post: #33




RE: 20FEB2017 SolveSys  Equation Library and Multiple Equations Solver
(02232017 11:46 PM)akmon Wrote: The program is solving smoother as versions upgrades. I´ve made a quick review to the equation library, and here are the flaws I detected, to confirm with your opinion: Verified that 3, 4, 6, and 7 will not solve. This is due to conflicts with R1 and R2 app variables in the Polar graphing app. Changing them to r1 and r2 seems to get around the issue and will likely be the published change. I personally feel this should be a firmware "bug" since app variables are supposed to have higher priority than builtin variables from other apps. We'll wait and see what the developers say. Other conflict messages you can ignore if the system can still be solved. System 7 fails on initial guess of all 1's  this is due to F being undefined during the initial iteration. I'll have to chase down this bug since it should have displayed an error rather in verbose mode. I was unable to find any issues with system E (DC Inductor Voltage) in terms of solving for values. Using 1, 2, 3, ..., 8 for the 8 variables gives me a solution. Did you have a different initial set of values that failed? Quote:Fluids As mentioned above, since you can still solve your system, these conflict messages can be safely ignored. They're mainly in place to help debug which builtin variables are useable and which are problematic (such as R1 and R2). Quote:Motion Confirmed. This is due to two missing variables vx and vy not being defined in the system itself. It appears from your hard work that apps that have functions as builtin variables (e.g. Function app and F0 through F9) currently has priority over usercreated app variables of the same name. So we will have to avoid these specific variables as well. Thank you for finding these; your help is greatly appreciated. I will publish an update to the library data file. Just to give you a heads up: for systems which use functions such as ZFACTOR, SIDENS, etc. you will unlikely be able to solve for the variables that are arguments for these functions. Those variables must be set as constants. In the future (and in theory) they will be solvable once I implement a numerical Jacobian routine, since the CAS most likely does not know how to provide analytical (partial) derivatives of these custom functions. EDIT: library file updated; see http://www.hpmuseum.org/forum/thread772...l#pid68580 Graph 3D  QPI  SolveSys 

02242017, 08:29 PM
(This post was last modified: 02262017 02:44 PM by Han.)
Post: #34




RE: 20FEB2017 SolveSys  Equation Library and Multiple Equations Solver
For anyone interested in the algorithm in the solver, here are some details: (link removed; see first post)
This is included in the manual that I am putting together. I should have a new update (with manual) soon. EDIT: reference manual in first post; includes details on algorithm Graph 3D  QPI  SolveSys 

02252017, 12:08 AM
Post: #35




RE: 24FEB2017 SolveSys  Equation Library and Multiple Equations Solver
First i have to say that you are doing a great job on the equation library.
i am new o this forum, first time here, I was wondering if someone could point me in the direction to fined information on what is need to view or edit the code for the hp prime. ie change variable names cut and paste updated patches. or be able to do this: this is from Han's post How would I go about doing this if I can not view the code. Here's a slight update to the app file "Equation Library.lib"  copy the list below and (in the virtual calc) type: AFiles("Equation Library.lib"):= <insert list below> .txt eqlib.lib.txt (Size: 45.3 KB / Downloads: 31) 

02252017, 12:52 AM
(This post was last modified: 02252017 12:54 AM by Han.)
Post: #36




RE: 24FEB2017 SolveSys  Equation Library and Multiple Equations Solver
(02252017 12:08 AM)vitruvianjp Wrote: First i have to say that you are doing a great job on the equation library. Regarding the attached file referenced in your post, the assumption is that you already have the Equation Library app installed on the virtual calculator (i.e. the emulator). Make sure that the Equation Library app is active (select it in the Apps menu). Use any text editor to open the attached text file and copy the contents (usually Ctrl+C on PC or Command+C on Mac). Then, in the virtual calculator, type into the command line: AFiles("Equation Library.lib"):= Don't press the [Enter] key yet. Instead (with the cursor to the right of the = symbol) paste the contents of the text file into the command line either using Ctrl+V (or Command+V on a Mac). Then press the [Enter] key on the virtual calculator. You can also paste using the menu Edit > Paste. Once your app is updated on the virtual calculator, you can simply transfer the entire app to your calculator (explained below). In this specific case, we are not patching any program source. Rather, the text file you are "patching" is merely a "data file" that holds all equations data. If you refer to the first post in this thread, you will always get the most updated version which requires no "patching" since it is the newest version. The zip file has installation instructions inside. However, there are times when I may post a quickfix for those who wish to manually "patch" their installation because I may not necessarily have an update to publish immediately. So if you do not want to wait for an official update, you can make modifications yourself using the following pointers:
Graph 3D  QPI  SolveSys 

02252017, 06:14 PM
Post: #37




RE: 24FEB2017 SolveSys  Equation Library and Multiple Equations Solver
First post updated with reference manual.
Graph 3D  QPI  SolveSys 

02262017, 01:33 AM
(This post was last modified: 02262017 05:17 PM by akmon.)
Post: #38




RE: 25FEB2017 SolveSys  Equation Library and Multiple Equations Solver
Fantastic, downloaded last version. Works very well. Also there reference manual is excellent, it explains the "core" of the app to solve the systems.
Even I have used it in my work, I had to solve a non linear system of equations and it solved it flawlessly. I tried with another example a "monster" system of equations: cos(A)^2sin(A)^2cos(B)*cos(A)=0 cos(B)^2sin(B)^2+sin(B)*sin(A)cos(C)*cos(B)=0 cos(C)^2sin(C)^2+sin(C)*sin(B)cos(D)*cos(C)=0 cos(D)^2sin(D)^2+sin(D)*sin(C)cos(E)*cos(D)=0 cos(E)^2sin(E)^2+sin(E)*sin(D)cos(F)*cos(E)=0 cos(F)^2sin(F)^2+sin(F)*sin(E)cos(G)*cos(F)=0 cos(G)^2sin(G)^2sin(G)*sin(F)=0 And the app "ate" the system without blinking. Anyway this system has a lot of posible solutions. Thank you for this masterpiece. I think it should be an "alpha" version now. 

02262017, 02:19 PM
Post: #39




RE: 25FEB2017 SolveSys  Equation Library and Multiple Equations Solver
Quite an impressive (and educational) application Han, convinced me to dust off my Prime and load it. Very cool.
Also, your manual is another impressive feat; quite thorough but easy to read and follow. Thanks for sharing this. One thing is not clear however, what are the advantages/disadvantages of using the combined vs. separated versions of the programs? Bob Prosperi 

02272017, 06:35 AM
Post: #40




RE: 25FEB2017 SolveSys  Equation Library and Multiple Equations Solver
(02262017 02:19 PM)rprosperi Wrote: Quite an impressive (and educational) application Han, convinced me to dust off my Prime and load it. Very cool. I will add more details in the next update to the reference manual. But simply put, the merged version is less accurate but much easier to maintain (from a user standpoint). This is the opposite in the separated version. Graph 3D  QPI  SolveSys 

« Next Oldest  Next Newest »

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