Polynomials: I’ve just made a text-based UI, slightly user-friendlier.

One of the facts which I’ve written about before was, that I had written a C++ program which finds numerical approximations to the roots of polynomials, preferably difficult polynomials to which there can be no exact solution. And one of the facts about my program, which I was never completely satisfied with, had less to do with the actual algorithm that gets closer and closer to each root, but has more to do with how my code could be inaccessible to those readers, who do not already know how to use a compiler.

Specifically, I had written a version of the program which somebody executes from ‘the Command Prompt’, as it’s called under Windows, because under Linux, power-users access features with one-line commands often. Yet, if a user was not such a power-user, then what they might do under Windows could be, just to double-click on the .EXE-File (the Application icon), observe that a console window briefly appears, and then watch it disappear again. There could be users who do not know how to navigate their Command Prompt windows to the folder into which they unzipped the program, and then execute that program from within their Command Prompt / Terminal Window.

And so, even though I kept the code roughly the same – it’s still text-based – I changed it subtly, to help out potential readers who may have had that problem. You may try it and see if you like it. The compressed files can be found at the following location:

https://dirkmittler.homeip.net/binaries/

And, within the table of contents which gets displayed there, the reader would either be interested in the file ‘Roots_Dirk_Mittler.tar.gz‘, or the file ‘Roots_Dirk_Mittler.zip‘ – in either case, the file-name that begins with a single ‘R’.

Enjoy,

Dirk

 

Simplifying the approach, to finding roots of polynomials.

In some cases, the aim of my postings is to say, ‘I am able to solve a certain problem – more or less – and therefore, the problem is solvable.’ It follows from this position that my solutions are not assumed to be better by any means, than mainstream solutions. So recently, I suggested an approach to finding the roots of polynomials numerically, again just to prove that it can be done. And then one observation which my readers might have made would be, that my approach is only accurate to within (10-12), while mainstream solutions are accurate to within (10-16). And one possible explanation for this would be, that the mainstream solutions polish their roots, which I did not get into. (:1)

(Edit 2/8/2019, 6h40 : )

A detail which some of my readers might have missed is, that when I refer to a ‘numerical solution’, I’m generally referring to an approximation.

(End of Edit, 2/8/2019, 6h40 . )

But another observation which I made, was that Mainstream Code Examples are much tighter, than what I suggested, which poses the obvious question: ‘Why can mainstream programmers do so much, with much less code complexity?’ And I think I know one reason.

The mainstream example I just linked to, bypasses a concept which I had suggested, which was to combine conjugate complex roots into quadratic terms, which could be factorized out of the original polynomial as such. What the mainstream example does is to assume that the coefficients of the derived polynomials could be complex, even though the original one only has real coefficients. And then, if a complex root has been found, factorizing it out results in such a polynomial with complex coefficients, after which to factorize out the conjugate, causes the coefficients of the quotient to become real again.

(Updated 6/02/2020, 16h35… )

I’ve just written some source-code of my own, to test my premises…

Continue reading Simplifying the approach, to finding roots of polynomials.

A Hypothetical Algorithm…

One of the ideas which I’ve written about often is, that when certain Computer Algebra Software needs to compute the root of an equation, such as of a polynomial, an exact Algebraic solution, which is also referred to as the analytical solution, or symbolic Math, may not be at hand, and that therefore, the software uses numerical approximation, in a way that never churned out the Algebraic solution in the first place. And while it might sound disappointing, often, the numerical solution is what Engineers really need.

But one subject which I haven’t analyzed in-depth before, was, how this art might work. This is a subject which some people may study in University, and I never studied that. I can see that in certain cases, an obvious pathway suggests itself. For example, if somebody knows an interval for (x), and if the polynomial function of (x), that being (y), happens to be positive at one end of the interval, and negative at the other end, then it becomes feasible to keep bisecting the interval, so that if (y) is positive at the point of bisection, its value of (x) replaces the ‘positive’ value of (x) for the interval, while if at that new point, (y) is negative, its value for (x) replaces the ‘negative’ value of (x) for the interval. This can be repeated until the interval has become smaller than some amount, by which the root is allowed to be inaccurate.

But there exist certain cases in which the path forward is not as obvious, such as what one should do, if one was given a polynomial of an even degree, that only has complex roots, yet, if these complex roots nevertheless needed to be found. Granted, in practical terms such a problem may never present itself in the lifetime of the reader. But if it does, I just had lots of idle time, and have contemplated an answer.

(Updated 1/30/2019, 13h00 … )

Continue reading A Hypothetical Algorithm…