cancel
Showing results for 
Search instead for 
Did you mean: 
Ciro_Bruno
Level 4
137 122 6 17
Message 1 of 8
882
Flag Post

[HP Prme] Spreadsheet containing Solve set of equations - a request for ideas.

HP Recommended
HP Prime
macOS 10.13 High Sierra

I'd like to ask your help with creative ideas.

 

I guess it's gonna take some time to reach the final solution. But ideas for the small steps will certainly be very useful.

 

I intend to solve a linear system using Spreadsheet as user's interface that may run a solve set of equations in background.

 

Please think about 3 or for rows of repetitive calculations through which the user will input all numerical data available and then the Solve app calculates the missing data. This calculation might be triggered by pressing a button.

 

Ideas are welcome.

 

Thank you.

Regards,

Ciro.

0 Kudos
7 REPLIES 7
cyrille
Level 6
Level 6
252 251 42 77
Message 2 of 8
Flag Post
HP Recommended

Hello,

 

Althrough they are other ways to do it (for example with an app program)... Here is one sollution.

 

It is kind of kludgy due to some idiosyncraties of the spreadsheet, but it works..

 

Assume that you enter the system in A1:C4, enter, for A5, the following formula:

=M3:=((M2:=A1:C3)^(-1)*(M1:=D1:D3))

 

Then, enter for A6 to C6: =M3(1), =M3(2) and =M3(3)

 

Here is why/how it works.

On the mathematic sides of thing, it works because if you put your system in a 3*3 matrix (M) form with the right side of the ax+by+cz=d equations in a vector (V), M^-1*V returns a vector which are the values for x, y and z... But I assume that you knew that.

 

A1:C3 will return a list of list which correspond to the "system" part of things. The problem is transforming it into a matrix. the cas list2mat can do this, BUT the cas can not extract values from the spreadsheet in the A1:C3 form as it does not know how to handle the ":" charater 😞

Hence the trick of storing the list of list into the M1 global variable. Since M1 is a matrix, the store operation will internally convert the list of list into a matrix and RETURN said matrix. Causing the transformation of the list of list into a matric.

We do the same for D1:D3 (vector) and M2. We can now easely do the math...

 

Now the next step is the extraction of the 3 components of the responce.

Normally var(n), when var is a composit (list or matrix) gives access to the various elements...

Problem is that in the spreadsheet, call(n) gives access to the cell meta data (value, equation, format...).

Which is why the equation in A5 has the M3:= store. This make sure that the result vector is stored in M3 and allows the A6, B6 and C6 to access the nth elements of the result...

 

As as I said, kludgy, but works...

 

Cyrille

I am an HP Employee
cyrille
Level 6
Level 6
252 251 42 77
Message 3 of 8
Flag Post
HP Recommended

Hello,

 

PS: you cna also use the linear solver app which does all of this for you...

 

Cyrille

I am an HP Employee
Tim_Wessman
Level 8
Level 8
747 744 121 185
Message 4 of 8
Flag Post
HP Recommended

To answer the other part of your question, there is no way to put a "button" to start a calculation. Spreadsheets always just calculate when changes happen. I'm not sure if  I've ever seen one that allows you to have buttons to "start" or anything.

TW

Although I work for the HP calculator group as a head developer of the HP Prime, the views and opinions I post here are my own.
cyrille
Level 6
Level 6
252 251 42 77
Message 5 of 8
Flag Post
HP Recommended

Hello,

 

By using a choose in the spreadsheet, you can do some type of UI driven program calls.

See the spreadsheet choose function help (Main, HP Apps, Spreadsheet, spreadsheet choose)...

 

Cyrille

I am an HP Employee
Ciro_Bruno
Author
Level 4
137 122 6 17
Message 6 of 8
Flag Post
HP Recommended

Yes, I'm using a CHOOSE already.

 

I must choose one component to be something like a "pivot" of the whole system.

 

I've seen you've given a very detailed idea. I should save tomorrow evening to read it mindfully and try it. I might return you some questions.

 

Thank you very much.

 

Best regards,

Ciro.

0 Kudos
Ciro_Bruno
Author
Level 4
137 122 6 17
Message 7 of 8
Flag Post
HP Recommended

Yes, I've seen it.

 

In fact, now I'm not sure it would be realy necessary.

 

When filling the spreadsheet with known value, I thought about placing the cursor somewhere at the "pivot" component's column, so the "Solve" considered these data as "frozen" and taking them to calculate the rest of the table.

 

I guess CHOOSE is doing the job quite well.

 

But I still am not sure exactly how to implement solve feature inside the spreadsheet.

 

Thank you very much.

Best regards,

Ciro.

0 Kudos
Ciro_Bruno
Author
Level 4
137 122 6 17
Message 8 of 8
Flag Post
HP Recommended

Hello Cyrille

 

Your solution is creative and sounds feasible. I guess the data extraction can be done in a program running loops and character recognition for data separation.

 

Reading the explanation I guess you understood by "solve" the CAS line command. However, I have in mind the Solve App. The option for combining both Apps (Spreadsheet and Solve) relies on two main reasons. Spreadsheet has the capability of showing data and data fields in organized way, making it easy for the user to read and input data. Solve allows the user to feed data according to their availability, leaving enpty the unknown value cells, then unknown data are calculaed

 

Thank you very much.

Regards,

Ciro..

0 Kudos
† The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation