HP Forums
Solving linear equations systems with > 9 variables accurately? - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: Not HP Calculators (/forum-7.html)
+--- Forum: Not quite HP Calculators - but related (/forum-8.html)
+--- Thread: Solving linear equations systems with > 9 variables accurately? (/thread-4087.html)



Solving linear equations systems with > 9 variables accurately? - Dieter - 06-05-2015 06:28 PM

I am currently designing two rational approximations for the Normal distribution's quantile function, with a working range from 0,5 to 1 E–99. The desired 10-digit accuracy (with a 13-digit implementation in HP41 MCODE) requires solving linear equation systems with 9...11 variables. I usually do this with Excel, but with 10-12 digit target accuracy of the solution this is simply not possible with Excel's 15 digit working precision.

So I did the 9-variable-case on a 34s. and the results came out accurately. Great, so this problem was solved. But 9 unknowns are the maximum the 34s can handle: it requires 81 registers for the matrix, 9 for the right hand side vector and another 9 for the solution, so 99 out of 100 registers are used.

But what can I do for the 10- or 11-variable case? I do not have access to Mathematica, Maple or other commercial math software, and I do not know a way to trick the 34s into handling larger matrices. Does anyone know of a (free) solution that runs on Windows XP/7? Or maybe there is a way using the 34s emulator...?-)

Dieter


RE: Solving linear equations systems with > 9 variables accurately? - Werner - 06-05-2015 08:11 PM

The Answer to Everything: (Free)42 !
34 digits, builtin matrix support, even 100x100 matrices are no problem.
Cheers, Werner


RE: Solving linear equations systems with > 9 variables accurately? - Marcio - 06-05-2015 08:36 PM

Scilab - open source is quite similar to Matlab and can handle any kind of system you need. Linear, non-linear, complex... Name it!

This is how to enter data:

x = [1 2; 0 4];

y = [4 5; 9 1];

Type x/y on the command line and you'll get the result. How sweet is that? You could also store the data to any var you want:

z = x/y

EDIT: If dealing with large amounts of data, you could import them from excel or type them using the variable editor. If that is the case, create 'x' first, ie x=[] on the command line, and then double click it on the variables browser to start keying in data using a spreadsheet that is automatically created for that particular variable.
After getting the results on the screen, you'll want to format them, do so like this:

format('v',3+12)

Hope it helps!


RE: Solving linear equations systems with > 9 variables accurately? - Dieter - 06-06-2015 07:19 PM

(06-05-2015 08:11 PM)Werner Wrote:  The Answer to Everything: (Free)42 !
(06-05-2015 08:36 PM)Marcio Wrote:  Scilab - open source is quite similar to Matlab and can handle any kind of system you need. Linear, non-linear, complex... Name it!

Werner and Marcio, thank you very much. I was not aware of Scilab as a powerful free numeric math package. I also did not know that the later releases of Free 42 use the decimal64 library for 34-digit precision without the well-known problems of binary encoded numbers. I think Free 42 should be able to calculate the matrix coefficents and then solve the resulting equation system. ;-)

Dieter


RE: Solving linear equations systems with > 9 variables accurately? - Bernd Grubert - 06-08-2015 11:51 AM

Hello Dieter,
There are even more free open source alternatives:
Numeric calculations: OCTAVE (a MATLAB clone), Python with numpy and scipy modules.
Symbolic/numeric calculations: MAXIMA.

Regards
Bernd


RE: Solving linear equations systems with > 9 variables accurately? - Marcio - 06-08-2015 12:20 PM

(06-08-2015 11:51 AM)Bernd Grubert Wrote:  Hello Dieter,
There are even more free open source alternatives:
Numeric calculations: OCTAVE (a MATLAB clone), Python with numpy and scipy modules.
Symbolic/numeric calculations: MAXIMA.

Regards
Bernd

Last time I used Octave was 3 years ago. It seems things improved considerably since then. There was not even a stable version for windows. I had to install cygwin (Unix-like environment and command-line interface for windows) to get it run to my satisfaction.
Octave now has a beautiful UI. Congrats to the development team!!


RE: Solving linear equations systems with > 9 variables accurately? - Paul Dale - 06-08-2015 09:47 PM

Dieter,

I believe we allowed matrices to occupy local registers on the 34S which would give you the space you require.


Pauli


RE: Solving linear equations systems with > 9 variables accurately? - Dieter - 06-09-2015 08:22 PM

(06-08-2015 09:47 PM)Paul Dale Wrote:  I believe we allowed matrices to occupy local registers on the 34S which would give you the space you require.

If I understand the manual correctly, the local registers correspond to addresses ≥ 112. So the 10x10 matrix would occupy R00...R99 and the right-hand side as well as the solution vector is stored in the local register area (≥ 112). Is this correct?

In the meantime I did the mentioned calculations on Free42 (decimal version). Works great.

Dieter


RE: Solving linear equations systems with > 9 variables accurately? - Paul Dale - 06-09-2015 10:01 PM

(06-09-2015 08:22 PM)Dieter Wrote:  If I understand the manual correctly, the local registers correspond to addresses ≥ 112. So the 10x10 matrix would occupy R00...R99 and the right-hand side as well as the solution vector is stored in the local register area (≥ 112). Is this correct?

Yep. It should also be possible to fit the 10x10 matrix in the locals depending on RAM allocation.


- Pauli


RE: Solving linear equations systems with > 9 variables accurately? - Dieter - 06-11-2015 10:54 AM

(06-09-2015 10:01 PM)Paul Dale Wrote:  Yep. It should also be possible to fit the 10x10 matrix in the locals depending on RAM allocation.

OK. But there's still one problem: AFAIK all local registers are lost as soon as the program terminates (RTN). So all calculations would have to be done in one single program run. My program however first calculates the matrix coefficients (get user input #i => calculate coefficients ai,1...ai,9 and bi) and afterwards the equation system is solved.

Dieter


RE: Solving linear equations systems with > 9 variables accurately? - DMaier - 06-14-2015 05:40 AM

(06-08-2015 11:51 AM)Bernd Grubert Wrote:  Hello Dieter,
There are even more free open source alternatives:
Numeric calculations: OCTAVE (a MATLAB clone), Python with numpy and scipy modules.
Symbolic/numeric calculations: MAXIMA.

Regards
Bernd

The J programming language, which has extended precision rationals, might also be of interest. (J was developed by Ken Iverson and Roger Hui as a successor to APL, so it's definitely focused on matrix manipulation.)