Creating an equation library (Updated 03-FEB-2017)
|
11-14-2015, 02:50 AM
(This post was last modified: 11-14-2015 02:50 AM by Han.)
Post: #41
|
|||
|
|||
RE: Creating an equation library (updated)
(11-14-2015 02:24 AM)Helge Gabert Wrote: So, in order to obtain the same DOT() result in CAS as in Home, Well, the CAS dot product is the "more correct" dot product for both real and complex vectors since the dot product of a vector with itself is generally considered to be the square of the norm of the vector (and this quantity is a real number, not complex). If a vector \( v \) is complex, the only way to guarantee a real-valued inner product of \( v \) with itself is to define \[ \langle v, v \rangle = v^H \cdot v \] where \( v^H \) is the Hermitian transpose (conjugate transpose) and \( v \) is assumed to be in "column" form. What I find amusing is that the ABS(v) command works the same in Home or CAS, whether the vector \( v \) is complex or real -- and the result is actually the square root of \( v^H \cdot v \) in the case where \( v \) is complex. I am not sure why the DOT() command in Home does not work the same way as dot() in CAS view. Graph 3D | QPI | SolveSys |
|||
11-14-2015, 03:30 AM
Post: #42
|
|||
|
|||
RE: Creating an equation library (updated)
I see your reasoning, but look at Wolfram Alpha, for example
dot([2+i,i],[9-i,7]) returns 19+14*i, just like it does in Home. http://www.wolframalpha.com/input/?i=dot...%2C7%5D%29 |
|||
11-14-2015, 05:25 AM
Post: #43
|
|||
|
|||
RE: Creating an equation library (updated)
(11-14-2015 03:30 AM)Helge Gabert Wrote: I see your reasoning, but look at Wolfram Alpha, for example I suppose if we were to be truly technical, then both the Prime and Wolfram would be incorrect in allowing vectors that are not real-valued since the "dot product" (being a special type of inner product) is for finite Euclidean spaces. Both Maple and Matlab disagree with Wolfram Alpha; their "dot" product uses the Hermitian inner product if the vectors are complex. Graph 3D | QPI | SolveSys |
|||
11-14-2015, 05:51 AM
(This post was last modified: 11-14-2015 05:51 AM by Helge Gabert.)
Post: #44
|
|||
|
|||
RE: Creating an equation library (updated)
OK, that is true, and open source platforms such as Octave (similar to Matlab) also return the hermitian inner product (in this example 17-18*i).
|
|||
04-23-2016, 04:50 PM
Post: #45
|
|||
|
|||
RE: Creating an equation library (updated)
I´ve checked this software in new firmware (10077), and after equation list, and press OK, a syntax error appears.
|
|||
01-27-2017, 05:47 PM
Post: #46
|
|||
|
|||
RE: Creating an equation library (updated)
Nothing like a nearly-year-long delay between a post and a response... but I finally had some time to get back to this project. This time, however, I am approaching it from the "other end" (i.e. interface).
Since we now have access to app files and app variables, it is easier (not really) to manage equations and variables from a programmer's point of view. The code below does nothing other than create an app for us to create systems of equations and save it in a library. If you copy the buit-in Solve app, and paste the code below into the copied app (I called it Equation Library, but you can use whatever name you want), then it should be ready to go. The app starts off by looking for an app file named "Equation Library.lib" which is supposed to be a list containing different systems of equations. If you don't have such a file, it will make one for you. Each system is itself a list consisting of a name, equations, variables, and the descriptions of the variables. You can use the [View] key to get more options such as adding another page of equations (since the Symb view only shows 10 at a time). To create a new system, start by creating your variables. Press [View] and select Add/Edit variables. Enter in a variable name and a description for the variable. Once your variables are created, you can start creating your equations. Save your system using [View]. Missing features are deletion (of variables, and of systems); that will come once we build a UI for browsing the list of systems. I am hoping to finally put everything together (the solver engine) so that this becomes a full blown equation library complete with solver and "file manager" to manage your various systems. In the meantime, people can play around with the code below if they want to start building their libraries. For those who do not speak English, the code is prepared in a way that should easily port to other languages (all the text are at the top of the source with the only exceptions being the [View] menu options). PHP Code: ssVersion:="Equation Library 0.01 by Han Duong"; Graph 3D | QPI | SolveSys |
|||
01-27-2017, 07:41 PM
Post: #47
|
|||
|
|||
RE: Creating an equation library (updated)
Hi Han
1: ISCHECK() Function not found =( 2: To contribute (in my case with Spanish), the messages in a list [English, French, Spanish, Portuguese] // app messages ssTNewVar:="Create/Edit Variable"; -> ssTNewVar:= [ "Create/Edit Variable", "Créer/Modifier la variable", "Crear/Editar Variable", "Criar/EditarVariável" ]; |
|||
01-27-2017, 07:51 PM
(This post was last modified: 01-27-2017 08:20 PM by Han.)
Post: #48
|
|||
|
|||
RE: Creating an equation library (updated)
(01-27-2017 07:41 PM)compsystems Wrote: Hi Han This would be a firmware issue. ISCHECK() was implemented some time ago, so your issue seems to suggest that you have firmware that is far too old. Quote:2: To contribute (in my case with Spanish), the messages in a list Once the program is actually out of "Proof of Concept" phase, then the messages will actually be implemented as a single list of strings. Each language will be its own separate list stored in a language file. In fact, variables such as ssTNewVar won't even exist anymore -- they will be converted into something like ssMsg[i] (the i-th messsage) where ssMsg is a list loaded from a language file, and the language is determined by the calculator's Language setting. Users will eventually be able to delete language files they don't need and the app will ask the user to choose from among the available language files if the Language setting in the calculator is not available among the language files. Graph 3D | QPI | SolveSys |
|||
01-30-2017, 11:10 PM
Post: #49
|
|||
|
|||
RE: Creating an equation library (updated)
Thank you Han, for this improvement. I´ve tested it in another thread with positive results.
Now the bad news. Don´t know why but after calculations, I press the app icon for start the program again, and it restart the calculator. There is some kind of variable stored that corrupt the system. Mu version is the newest on physical calculator. So the first time has worked flawlessly, the second or next, restart. |
|||
01-31-2017, 12:16 AM
(This post was last modified: 01-31-2017 08:58 AM by Han.)
Post: #50
|
|||
|
|||
RE: Creating an equation library (updated)
Yes, it is likely due to a bug related to input forms (avoid choose lists in input forms if you cannot guarantee that the lists are never empty). I'll be posting an update shortly that provides a workaround and includes part of the solver engine.
EDIT: very basic solver in place (only works on systems whose Jacobian is invertible). Use [View] Menu for managing systems of equations. [Plot] is a hotkey for choosing a system that has been archived. [Num] starts the solver. [NumSetup] provides variable management. (Currently cannot delete variables). Very alpha-ish release. Don't do obvious "no-no" things like trying to solve an empty system of equations. PHP Code: ssVersion:="Equation Library 0.05 by Han Duong"; Graph 3D | QPI | SolveSys |
|||
01-31-2017, 01:35 PM
Post: #51
|
|||
|
|||
RE: Creating an equation library (updated)
Thnks for version 0.05, but I still get a restart on my phisical unit when I press [Num], [Plot] or [View] and then option "Add or edit variable"
However, on my virtual calculator it works well. Could be there is some old files from the earlier version on my phisical calculator that corrupts the system? And is there an option for solving system of equations "on the go" using your engine, for just inserting the equations without defining the variables previously?. The variables will be created automatically in the solver menu ([Num]). |
|||
01-31-2017, 02:55 PM
(This post was last modified: 01-31-2017 04:53 PM by Han.)
Post: #52
|
|||
|
|||
RE: Creating an equation library (updated)
(01-31-2017 01:35 PM)akmon Wrote: Thnks for version 0.05, but I still get a restart on my phisical unit when I press [Num], [Plot] or [View] and then option "Add or edit variable" I have only been using the program on the virtual calc and so far have not had any crashes other than the empty choose list I described earlier. Are you pressing [Num] prior to inputting any variables and equations? It may be you are still running into empty list issues if so. The solver right now makes little to no checks whether there is a valid system; you will need to ensure that it does. The last thing to check is if your "Equation Library.lib" app file is not corrupt. Back it up, and simply delete it. EDIT: So I just tried to run it on the actual calculator and am seeing some warmstarts (calculator resets). I managed to trace it down to the return() statement in the ssInitVars() program. It looks like either you and I have both the same memory corruption, or there is indeed a bug the current firmware with respect to return() within an app. Quote:And is there an option for solving system of equations "on the go" using your engine, for just inserting the equations without defining the variables previously?. The variables will be created automatically in the solver menu ([Num]). No, and that is due to a limitation of how variables are created on the calculator. (In order to use the built-in equation editor in the Symb view, only existing variables are allowed.) One can only hope that in the future they will modify app behaviors so that entering formulas in the symbolic view, app variables are automatically created. I am not sure why that has not been made to be the default behavior. At the moment, I prefer not to have to build a custom equation editor. Graph 3D | QPI | SolveSys |
|||
02-01-2017, 12:36 AM
Post: #53
|
|||
|
|||
RE: Creating an equation library (updated)
(01-31-2017 01:35 PM)akmon Wrote: And is there an option for solving system of equations "on the go" using your engine, for just inserting the equations without defining the variables previously?. The variables will be created automatically in the solver menu ([Num]). So I thought about this a bit more and there are some alternatives we can consider. Using only global variables (A-Z,theta,Z0-Z9) could work for "on-the-fly" use. I believe I can properly parse all relevant variables so that users never have to specify them as being part of the the variables list provided that these variables are restricted to global types. Again, the limitation is mainly in the command line in the Symb view. It does not allow you to type expressions using non-existent variables (so globals work, but something like 'myvar' will not unless it already exists in the system). For the moment, this is not too high on my priority list. I would rather focus on the convergence of Newton's method, and the error handling for different systems (ill-conditioned, over/under determined, etc.) If enough people would like an on-the-fly setup, then perhaps we can then bump it up to higher priority. Graph 3D | QPI | SolveSys |
|||
02-01-2017, 11:24 AM
Post: #54
|
|||
|
|||
RE: Creating an equation library (updated)
I agree that the firs step is working on the engine of solving the system, that´s true.
In my hopes, I admit I´m nostalgic with the old Solvesys library from Hp48, 49, I inserted several equations, and the program "ate" them solving the variables amazingly, with no need to create them. So now you know which are my priorities. Of the course, managing files of equations i awesome and useful, but it´s easier to program. The main engine is the most important part of the proyect, my point of view is have both worlds for using from a way or other: the file manager stores all equations, clasified with menus, choose boxes etc. But once the equations are selected, launch the engine to solve them, or if you don´t want to use the file manager, and just only press the engine and solve some equations "on-the-fly" it could be done. The problem is the automatic creation of variables, it´s strange there is no command that extracts them from the equation. |
|||
02-01-2017, 12:35 PM
(This post was last modified: 02-01-2017 12:36 PM by Han.)
Post: #55
|
|||
|
|||
RE: Creating an equation library (updated)
(02-01-2017 11:24 AM)akmon Wrote: I agree that the firs step is working on the engine of solving the system, that´s true. Once the equations have been created, then extracting variables can be done using LNAME. However, one cannot enter equations into the Symb view using variables that do not already exist (i.e. entering equations that involve only global variables like A-Z is ok, but using a custom variable name that has never been created will result in an syntax error when using the Symb view). That is just a quirk with the HP Prime's non-CAS side -- you cannot enter formulas that use variables that do not exist. Using the Symb view means not having to create a brand new interface for entering functions (plus, it gives you pretty-print AND it has some basic form of syntax checking). And the Symb view's behavior is the only reason users have to first "create" non-global variables. In the end, I went ahead and enforced this rule for all variables for consistency. Another motivating factor was that for an equation library, the variables should really have some sort of description, which could be added during the variable editing/addition step. I too loved how you could just make a symbolic expression on the HP48-HP50 series and never have to "declare" variables. From time to time, it still bugs me that it is not always the case on the HP Prime. Graph 3D | QPI | SolveSys |
|||
02-01-2017, 03:24 PM
(This post was last modified: 02-01-2017 03:36 PM by Han.)
Post: #56
|
|||
|
|||
RE: Creating an equation library (updated)
Here's a version that _should_ enable automatically manage pre-existing variables so that you do not have to manually add them to the system. If they already exist, then they will be included into the system definition on the fly (with an empty description that can be changed using the add/edit variable menu item in [View]).
Source here: http://www.hpmuseum.org/forum/thread-2824.html You will need to manually set the flag ssAutoVar to 1 using: ssAutoVar:=1; In the future, this will probably default to 0 (because users need to understand that the HP Prime simply will not auto-create user variables). The intent is that this setting and can be changed via a settings page (does not exist yet; have not coded it). The code is posted in the very first post. I'll be updating only the first post from here on out so that: 1) we don't keep bumping this thread unnecessarily 2) it doesn't grow in size with newer versions (i.e. only the code in the first post will change as updates occur) Once it is in a release state, I'll move it into the software library forum. Graph 3D | QPI | SolveSys |
|||
02-02-2017, 11:46 PM
Post: #57
|
|||
|
|||
RE: Creating an equation library (Updated 1-FEB-2017)
So it looks like we've hit another snag. The SVD technique for pseudo inverses handles literally all possible cases of systems (over determined, under determined, ill conditioned, etc). The problem is that the SVD as implemented on the calculator is incomplete (it does not handle matrices with 0 as a singular value). I tried to use my own SVD program, but it would appear that it too has issues -- issues which I cannot trace as of yet. It also doesn't help that the exact same code on the HP returns something different from xcas
Graph 3D | QPI | SolveSys |
|||
03-05-2017, 09:50 PM
Post: #58
|
|||
|
|||
RE: Creating an equation library (Updated 03-FEB-2017)
I thought this thread needed a proper conclusion. For those who do not already know, this project now exists as an actual app: http://www.hpmuseum.org/forum/thread-7725.html
All issues with the SVD program are now resolved (to the best of my knowledge). As a side note, the reference manual has been updated. (I am particularly fond of page 41 in the reference manual; see link above for more info) Graph 3D | QPI | SolveSys |
|||
03-06-2017, 11:55 AM
Post: #59
|
|||
|
|||
RE: Creating an equation library (Updated 03-FEB-2017)
I have been following this thread with interest but I won't actually need such a program. I do need your SVD program separate from the Solvesys program, though. Is that available in the latest version?
Thanks! |
|||
03-06-2017, 12:04 PM
Post: #60
|
|||
|
|||
RE: Creating an equation library (Updated 03-FEB-2017)
Never mind! I just found it. Thanks for your contribution!
|
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 6 Guest(s)