TSE: Math: How to calculate the eigenvalues and eigenvectors of a given matrix? Method: QR-Algorithm: PowerShell

28 views
Skip to first unread message

knud van eeden

unread,
Jul 17, 2025, 7:25:12 PM7/17/25
to SemWare TSE Pro Text Editor
 Q. TSE: Math: How to calculate the eigenvalues and eigenvectors of a given matrix? Method: QR-Algorithm: PowerShell

Hello,

1. -See also optionally:


2. -To run the program:

     1. -Compile the attached program

          getmaepo.s

     2. -Run the program

     3. -Input the given matrix
         (must be square)

     4. -For example

          Let say the matrix is

            1 2

            3 4

          The first number is the dimension of the matrix, e.g. here 2

          The next 4 numbers are the elements of that matrix

          thus here 1 2 3 4 (separated by spaces.

          So concatenating this would give as input

           2 1 2 3 4

     5. -For example

          Let say the matrix is

            1 2 3

            4 5 6

            7 8 9

          The first number is the dimension of the matrix, e.g. here 3

          The next 9 numbers are the elements of that matrix

          thus here 1 2 3 4 5 6 7 8 9 (separated by spaces.

          So concatenating this would give as input

           3 1 2 3 4 5 6 7 8 9

     6. -The output will show

          1. -The eigenvalues

          2. -The eigenvectors

         of that given matrix

         E.g.

          Eigenvalues

           5.37228132326902

           -0.372281323269014

          Eigenvectors

           0.415973557919284,0.909376709132124

          -0.824564840132394,0.565767464968992

     7. -Tested successfully
         on
         Microsoft Windows 10 Professional (64 bits)
         running
         TSE for Microsoft Windows version 4.50 RC24

3. -To calculate the eigenvalues and eigenvectors of a given matrix
    here the QR-Algorithm is used, implemented in PowerShell

     Source: Artificial Intelligence (=AI): ChatGPT

     Tried also Claude (less correct answers), DeepSeek and Gemini (too many iterations necessary), Mistral (too many errors)

4. -My first idea was to use the fact that to find the eigenvalues one
    has to solve a Nth degree equation, e.g. of the quadratic 2nd, cubic
    3rd, quartic 4th, quintic 5th, ... degree.

    This approach because I had already created TSE programs to get the
    roots of 1st, 2nd, 3rd, 4th and 5th degree equations.
    So that would come very useful here.

    The coefficients e.g. a, b, c, d, e, f of the Nth degree follow from working out
    a 2x2, 3x3, 4x4, 5x5, ... determinant.

    Albeit working out a 2x2 determinant is simple,

    You get then in general as coefficients of the quadratic equation a . x^2 + b . x + c = 0

     a = 1

     b = -x11 -x12

     c = x11 . x22 - x12 . x21

    When working out a 3x3 determinant is already more involved.
    then calculating a . x^3 + b . x^2 + c . x + d = 0
    where

    long calculations ...

     a = ...

     b = ...

     c = ...

     d = ...

    When working out a 4x4 determinant is already even more involved.
    then calculating a . x^4 + b . x^3 + c . x^2 + d . x + e = 0
    where

    long calculations ...

     a = ...

     b = ...

     c = ...

     d = ...

     e = ...

    When working out a 5x5 determinant is already even much more involved.
    then calculating a . x^5 + b . x^4 + c . x^3 + d . x^2 + e . x + f = 0
    where

    long calculations ...

     a = ...

     b = ...

     c = ...

     d = ...

     e = ...

     f = ...

5. -So as a next step instead of using a more exact approach to use a numerical
    approach.

    The QR-algorithm seemed a good method, so asked the Artificial
    Intelligence (=AI) to implement that in PowerShell.

    That worked out OK, with very good output coming only from ChatGPT this time.

6. -Some background

     1. -A matrix is nothing more than a 'bare bones' representation
         of a set of (linear) equations.
         Typically the variable names (e.g. x, y, z, ...) are left out
         completely, only the numbers (e.g. 0.56, 1.23, ...) are
         shown and are left.

          For example

           2 . x + 3 . y = 0

           4 . x + 5 . y = 0

           would give the matrix

             2  3

             4  5

     2. -In general a multiplication of a matrix and a vector gives a new
         vector but and rotated and stretched.

         The eigenvector is a very special and simpler new vector that is not
         rotated but only stretched.

         You get a simpler system thus usually.

     3. -All you need to begin with is a given (square, thus NxN) matrix.
         Nothing else to begin with.
         From that you calculate its N eigenvalues.
         Typically by solving an Nth degree equation.
         From those eigenvalues you calculate its eigenvectors.

     4. -From that given (square) matrix you can calculate some special
         vectors that only stretch but do not rotate when multiplied
         with that given matrix.

     5. -That explains also the German word 'eigen' here, which means 'coming
         from itself', thus here coming intrinsically and inherently from
         (only) that given (square) matrix 'itself' thus.

     6. -A 2x2 matrix could give 2 eigenvalues, 3x3 could give 3 eigenvalues,
         4x4 could give 4 eigenvalues, ..., NxN matrix could give N eigenvalues.
         You will have to solve an Nth degree equation to find
         the N eigenvalues.
         Then from these N eigenvalues you can usually determine the
         N eigenvectors.

     7. -In general why would you multiply a matrix and a vector? Because you
         want to perform a transformation (like a translation, a rotation,
         ...).

          For example:

           Rotate all single points of a given figure over 45 degrees then at
           the end that whole figure is indeed rotated over 45 degrees.

           And each single point is thus a vector.

           And in case of this rotation of all points of a given figure you
           would go for that special matrix that ONLY rotates but NOT
           stretches. Because if it should stretch then the points or thus
           vectors should be distorted as end result.

     8. -So in general given a given matrix to multiply with then 4 special
         new vector endresults are possible:

          1. vector ONLY ROTATES but does NOT stretch.

          2. vector ROTATES AND STRETCHES.

          3. vector NO CHANGE at all.

          4. vector NO rotation but ONLY STRETCHES.

              This last situation is an eigenvector thus.

              The amount that vector is stretched (or compressed) is the
              eigenvalue thus.

     9. -Usage of eigenvalues: Simplifying complex transformations: Imagine
         trying to understand a complicated process that rotates, stretches,
         and shears things in many different ways. Eigenvectors act like
         special compass needles that point in directions where the
         transformation is simplest - just a stretch or compression. This
         makes analyzing and predicting the behavior of the system much
         easier.

with friendly greetings
Knud van Eeden


getmaepo.s

Carlo Hogeveen

unread,
Jul 18, 2025, 6:41:54 AM7/18/25
to sem...@googlegroups.com

 

Hi Knud,

 

I notice that this is just a powershell script, the source of which is wrapped in a TSE macro.

Your macro just saves the powershell script and then calls it from TSE.

Its only use is, that you can call the powershell script a TSE macro and publish it in the TSE mailing list.

 

Carlo

 

 

Knud van Eeden

unread,
Jul 18, 2025, 8:53:32 AM7/18/25
to sem...@googlegroups.com, Knud van Eeden
OK, sure, just go ahead and write your eigenvector and eigenvalue TSE program in TSE SAL.

Talk to you later ...


--

---
You received this message because you are subscribed to the Google Groups "SemWare TSE Pro text editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to semware+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/semware/001b01dbf7d0%248fc80430%24af580c90%24%40ecarlo.nl.

Knud van Eeden

unread,
Jul 18, 2025, 8:55:58 AM7/18/25
to sem...@googlegroups.com, Knud van Eeden
and do not forget then also to let it run on a remote server in TSE g32.exe.

Knud van Eeden

unread,
Jul 18, 2025, 8:59:21 AM7/18/25
to sem...@googlegroups.com, Knud van Eeden
and do also not forget to let it run in TSE Linux on Linux WSL and possibly Linux non-WSL when writing it in pure TSE SAL.

Again talk to you later some time in the future.

H P

unread,
Jul 18, 2025, 12:24:22 PM7/18/25
to sem...@googlegroups.com
Knud,

I think that Carlo means, why would you put a powershell script in a tse script  and execute it from there.
It means that the powershell script still will be executed in powershell but now also tse is in memory so it's not extremely powerful because the only thing what happens is that your now using tse as a menu-program.
Your processor will now swap instructions from tse and powershell and thus also use more energy.
Writing powershell-scripts with tse is good although powershell itself controls the writings of your statements what tse doesn't, but if the script is finished you can put this in a separate directory to start them from there.


Met vriendelijke groet,
With kind regards,
Muy atentamente,
Mit Freundliche Gruß,
Sinceramente,


H. Pikaar

Henri...@gmail.com



Op vr 18 jul 2025 om 14:59 schreef Knud van Eeden <knud.va...@gmail.com>:

Knud van Eeden

unread,
Jul 18, 2025, 1:03:48 PM7/18/25
to sem...@googlegroups.com, Knud van Eeden
Thus really looking forward to your pure TSE SAL floating point program included a scientific functions library running on Microsoft Windows and Linux.



Knud van Eeden

unread,
Jul 18, 2025, 7:17:41 PM7/18/25
to sem...@googlegroups.com, Knud van Eeden
As usual we are dealing with a very big provocateur and large disturber who comes up once in a while to spread his very negative sentiments around and who is thus clearly only after disturbing things willfully

Spreading all kind of big non-sense statements like the one above and having no or zero knowledge at all about such things thus, completely ignorant thus.


On Fri, Jul 18, 2025 at 12:41 PM Carlo Hogeveen <t...@ecarlo.nl> wrote:
--

Guy Rouillier

unread,
Jul 19, 2025, 8:20:57 AM7/19/25
to Semware TSE Pro
I don't understand the emails I'm receiving trying to get TSE SAL to do all sorts of things, like a floating point calculator.  Both Windows and Linux desktop operating systems come standard with fully capable calculators, including floating point calculations.  So we don't need to shoehorn all this functionality into TSE.  Let's just keep TSE focused on text editing and other programmer related tasks, like running a compiler and stepping through and found errors.  Even there, avoid the temptation to make TSE into a full-featured IDE, as plenty of those are available at little or no cost.

Thanks.

--
Guy Rouillier

knud van eeden

unread,
Jul 19, 2025, 8:33:38 AM7/19/25
to sem...@googlegroups.com
Stand still and do not move forward and question (all) new changes.

The rest moves on and embraces the incredible changes nowadays.

Sent from Yahoo Mail on Samsung Galaxy S24 Ultra / 1 terabyte / artificial intelligence

knud van eeden

unread,
Jul 19, 2025, 9:06:44 AM7/19/25
to sem...@googlegroups.com


1. Microsoft Windows scientific calc.exe, the only native Microsoft Windows application in that regard is NOT an option for automated calculations from within TSE (programs) thus.
So bye bye thus to that proposed option.

2. Text editors like Slickedit have built-in floating point calculations out of the box already for estimated 30 years or more.










Sent from Yahoo Mail on Samsung Galaxy S24 Ultra / 1 terabyte / artificial intelligence

Carlo Hogeveen

unread,
Jul 19, 2025, 9:39:31 AM7/19/25
to sem...@googlegroups.com

Hi Knud,

That was a lot of name calling and requests to reproduce "your" work.
All that just for making a short observation.

That is OK.
Being on the other side of the Dunning Kruger spectrum I actually value being critiqued.
And I am experienced enough to sift the content from the emotion.

About your request to write an eigenvector and eigenvalue TSE program in SAL.
I looked up eigenvectors and eigenvalues.
I was expecting some high-level math, but those are just names for mathematical algorithms, which can be implemented by doing a lot of multiplications and additions in loops.
Sorry, that is not much of a challenge.

About your request to use TSE to handle server requests.
I actually did that once, back when I was little and had the use of a Windows server.
It only works in Windows servers.
Linux TSE requires a terminal to run from, and aborts when instead being called by the server.
I appreciate the nerdiness of running TSE as a server, so goody for you.

About your request to create a pure SAL floating point program including scientific functions.
That one is actually already on my list of planned macros, though I will limit scientific functions to the ones I see a need for.
Not as yet another calculator, as Guy understandingly has no need for, but for me as a macro programmer to be able to use floating point numbers in macros.
Maybe one day.

Then there were a string of posts about the value of dynamically generated programs.
I totally agree with that.
But your "TSE macro" does not do that.
It does nothing to dynamically generate the PowerShell script, it just saves it as is, which is called statically.
So your "TSE macro" is just a wrapper around a static PowerShell script.

Here is my analysis of what is going on.
A few years ago AI became hot.
In a short time it became somewhat capable of programming.
But only in programming languages for which a lot of training data was available, like Python, C and PowerShell.
At the same time you became a programmer in the sense that you began to publish Python and C programs in the TSE mailing list, and now PowerShell scripts.
You valiantly attempted to generate TSE macros with AI, but the AIs were not up to it.

Here is my advice.
For now there is no need to publish cringy "TSE macros" to the TSE mailing list.
Just publish your AI-generated Python, C and Powershell programs as themselves, like you have been doing before.
It has the advantage that you can tweak them in editors that can syntax-hilite, syntax-check, and otherwise support those languages.

I am looking forward to see you have fun with eigenvectors and eigenvalues,
Carlo




Reply all
Reply to author
Forward
0 new messages