Mathematician Finds Easier Way to Solve Quadratic Equations
|
05-05-2024, 01:18 PM
Post: #41
|
|||
|
|||
RE: Mathematician Finds Easier Way to Solve Quadratic Equations
(05-05-2024 06:31 AM)carey Wrote:(05-05-2024 02:24 AM)Namir Wrote: Wat's next? Solving systems of linear equations using Cramer's rule??? In the late 80s I attended a programmers' conference in Boston. A speaker mentioned that he encountered a math application that was running WAY TOO SLOW! When he checked the source code, he found that the code author was using Cranmer's method to solve linear equations. You should have heard the attendees reaction .. a resounding ouuuuuuuh!!! Just sharing! |
|||
05-05-2024, 01:23 PM
Post: #42
|
|||
|
|||
RE: Mathematician Finds Easier Way to Solve Quadratic Equations
(05-05-2024 11:07 AM)Thomas Klemm Wrote:(05-05-2024 02:24 AM)Namir Wrote: Wat's next? Solving systems of linear equations using Cramer's rule??? I don't see Cranmer's rule mentioned much in Numerical Analysis books when they discuss the topic of solving linear equations.`I guess these authors maintain a reasonable bar for algorithms used to solve linear equations. Namir |
|||
05-05-2024, 02:47 PM
Post: #43
|
|||
|
|||
RE: Mathematician Finds Easier Way to Solve Quadratic Equations
(05-05-2024 02:24 AM)Namir Wrote: Let's keep in mind the KISS principle (keep it simple stupid), or what Einstein said, "Make it simple, but no simpler". Using fancy functions like cosh, exp, sin, and so on is fancy, but introduces a bit of complicatrion in my very humble opinion.I strongly believe KISS doesn’t apply when you are just having fun… |
|||
05-05-2024, 05:45 PM
(This post was last modified: 05-05-2024 05:47 PM by carey.)
Post: #44
|
|||
|
|||
RE: Mathematician Finds Easier Way to Solve Quadratic Equations
(05-05-2024 01:18 PM)Namir Wrote:(05-05-2024 06:31 AM)carey Wrote: And what’s wrong with using Cramer’s rule for linear systems? Yes, Cramer's rule is awful as a numerical method, but, using symbolic determinants, as the IEEE article linked in my previous tongue-in-cheek reply shows, offers unique advantages for obtaining symbolic results, e.g., transfer functions at any point in a linear system. The classic books Network Analysis and Feedback Amplifier Design by Hendrik Bode and Control-System Dynamics by Walter Evans (originator of the root-locus method), make good use of Cramer's rule to derive symbolic results. |
|||
05-05-2024, 06:13 PM
(This post was last modified: 05-05-2024 06:23 PM by Gerson W. Barbosa.)
Post: #45
|
|||
|
|||
RE: Mathematician Finds Easier Way to Solve Quadratic Equations
(05-05-2024 02:24 AM)Namir Wrote: Let's keep in mind the KISS principle (keep it simple stupid), or what Einstein said, "Make it simple, but no simpler". Using fancy functions like cosh, exp, sin, and so on is fancy, but introduces a bit of complicatrion in my very humble opinion. I fear you have completely missed the point. We could, for instance, apply the identity \(\arcsin{z}=\arccos{\sqrt{1-z^2}}\) to \[x_{1}=\left({\cos\left({\arcsin{\frac{\sqrt{q}}{-\frac{p}{2}}}}\right)+1}\right)\times-\frac{p}{2}\] and easily take the trigonometric functions out of the formula. But then we would get back to the original pq formula, which as we know cannot handle, on a 12-digit calculator, the first example in Palmer’s article, a=1E-13, b=-2 and c=1, whose roots at that precision are 2E13 and 0.5, not 2E13 and zero. Of course that is not a concern on Free42 if we are interested solely in 12-digit answers. Sure these have some shortcomings, like b or c having to be different from zero, depending on the formula we choose, or real results being shown with null imaginary parts in certain cases, for example when a=1, b=-1 and c=-2. The use of transcendental functions are just trade-offs for a little more accuracy while keeping compactness. In a failed attempt (complex number is an invalid type for the LN1+X function), in order to keep the stack register T intact I would use – horror of horrors! – four transcendental functions in a row. Regards, Gerson. ———————- Code:
|
|||
05-05-2024, 06:41 PM
Post: #46
|
|||
|
|||
RE: Mathematician Finds Easier Way to Solve Quadratic Equations
(05-05-2024 12:48 PM)Maximilian Hohmann Wrote: But apart from that I keep wondering why the quadratic equation and it's memorized solution is attributed such a high significance by schools. I have never since finishing school come across a quadratic equation in real life. Things are mostly simple and can be handled with linear calculations ("if my plane needs 1400 pounds of fuel in one hour, how much must I take along for a 2:25h flight?") or they are really complicated and require higher order polynomials, transcendental funcions or numeric solutions. But a quadratic equation? Never ever. Hmm...there are a lot of equations in nature that involve squares (e.g., inverse square laws for electrostatics, gravity, light and sound intensity, quadratic dependence of power on current, quadratic dependence of air drag on velocity, etc.) that, in all but the simplest examples that only require taking a square root, lead to quadratic equations. Paraphrasing Abraham Maslow, "if all you have is y=mx+b, the whole world looks like a line." |
|||
05-05-2024, 07:37 PM
Post: #47
|
|||
|
|||
RE: Mathematician Finds Easier Way to Solve Quadratic Equations
(05-05-2024 12:48 PM)Maximilian Hohmann Wrote: Things are mostly simple and can be handled with linear calculations Extra weight of fuel will require some fuel to transport. Effect may be small, but this is not a linear calculation! |
|||
05-05-2024, 07:41 PM
Post: #48
|
|||
|
|||
RE: Mathematician Finds Easier Way to Solve Quadratic Equations
(05-05-2024 06:13 PM)Gerson W. Barbosa Wrote: complex number is an invalid type for the LN1+X function Free42/Plus42 now has C.LN1+X to handle complex input. https://github.com/thomasokken/free42/issues/55 To make this work, LN accuracy has improved as well. https://github.com/thomasokken/free42/issues/62 |
|||
05-05-2024, 09:18 PM
Post: #49
|
|||
|
|||
RE: Mathematician Finds Easier Way to Solve Quadratic Equations
Hello,
(05-05-2024 07:37 PM)Albert Chan Wrote: Effect may be small, but this is not a linear calculation! Yes, but for daily work this is done using tables (until 20 years ago) or rather software on a computer (since 20 years) or an iPad App (since 10 years). My question really remains: Who has ever, in professional or private life, used his memorised "midnight formula" (no idea if it is called that in English, in German we call it "Mitternachtsformel" because you can wake up any schoolchild at midnight and she or he will be able to recite that equation) for a real calculation? And if not, why on earth did they waste our time with this nonsense at school instead of teaching us something useful? Regards Max |
|||
Yesterday, 12:23 AM
Post: #50
|
|||
|
|||
RE: Mathematician Finds Easier Way to Solve Quadratic Equations
Perhaps I should invoke the KISS rule to myself. The accuracy of the second root can be improved simply by calculating it as x₂ = q/x₁, x₁≠ 0, assuming of course that the first root is accurate enough. If the first root is zero the program stops and a “Divide by 0” message is shown, but then again in this case a quadratic solver is not needed.
The program has been relabeled as “Y” (why hadn’t I done it this way yet?). Only 22 bytes and 13 steps, including LBL and END. Code:
Example: \(10^{-13}x^2-2x+1=0\) E +/- 13 ENTER 2 +/- ENTER 1 XEQ Q -> HP-42S: T: previous X Z: previous X Y: 0.5 X: 2.E13 Free42: T: previous X Z: previous X Y: 0.500000000000012500000000000625 X: 19,999,999,999,999.4999999999999875 |
|||
Yesterday, 02:32 AM
Post: #51
|
|||
|
|||
RE: Mathematician Finds Easier Way to Solve Quadratic Equations | |||
Yesterday, 03:11 AM
Post: #52
|
|||
|
|||
RE: Mathematician Finds Easier Way to Solve Quadratic Equations
(Yesterday 02:32 AM)Albert Chan Wrote:(Yesterday 12:23 AM)Gerson W. Barbosa Wrote: The accuracy of the second root can be improved simply by calculating it as x₂ = q/x₁ I was aware of that. That’s why I added “assuming of course that the first root is accurate enough”. No problem with the few examples I tried, though. Perhaps I need a more comprehensive list of examples to check. Considering the possibilities you mention, I think it’s better to compute the second root as x₂ = -(b + x₁). At least divisions by zero are completely avoided. |
|||
Yesterday, 06:15 AM
(This post was last modified: Yesterday 10:31 PM by carey.)
Post: #53
|
|||
|
|||
RE: Mathematician Finds Easier Way to Solve Quadratic Equations
Max, respectfully, your earlier point seemed to be that the quadratic equation is relatively unimportant because, in your opinion, linearity reigns supreme.
(05-05-2024 12:48 PM)Maximilian Hohmann Wrote: I have never since finishing school come across a quadratic equation in real life. Things are mostly simple and can be handled with linear calculations ("if my plane needs 1400 pounds of fuel in one hour, how much must I take along for a 2:25h flight?") or they are really complicated and require higher order polynomials, transcendental funcions or numeric solutions. But a quadratic equation? Never ever. Now your point seems to have shifted to the quadratic formula for solving quadratic equations is implemented in software, so why learn it. (05-05-2024 09:18 PM)Maximilian Hohmann Wrote: Yes, but for daily work this is done using tables (until 20 years ago) or rather software on a computer (since 20 years) or an iPad App (since 10 years). The former is the view that quadratic equations are unimportant, while the latter is the view that the quadratic formula for solving quadratic equations is unimportant. Respectfully, I find both views mistaken. 1) The number of uses for quadratic equations is so numerous, and in so many fields, that listing them is like listing uses of the Pythagorean theorem. (see EdS2's current thread for a few examples). 2) Besides the obvious that it's good to understand equations even if we use software to implement them, the quadratic formula in symbolic form is essential for determining equilibria and bifurcations in nonlinear ODE's (for which software is limited to numerical solutions since most nonlinear ODEs have no closed-form solutions). For example, to find equilibria solutions and bifurcations in the nonlinear ODE \[ \frac{dy}{dt} = y^2 +2y + a \] set it equal to 0, resulting in a non-factorable quadratic equation \[y^2 + 2y + a = 0\]. Solving for y in terms of parameter a using the quadratic formula \[-b \pm \frac{\sqrt {(b^2 - 4ac)}}{2a} \] \[-2 \pm \frac{\sqrt {(4 - 4a)}}{2} \] \[-1 \pm \sqrt {(1 - a)} \] we obtain an expression (1 - a under the radical) that gives the number of equilibrium solutions and shows the importance of the quadratic formula used as a symbolic equation. Case 1: If 1-a =0, then a = 1 and there is a single equilibrium solution: y=−1. Case 2: If 1-a>0, then a <1 and there are two equilibrium solutions: $$-1 \pm \sqrt {(1 - a)} $$ Case 3: If 1-a <0, then a>1 and there are no equilibrium solutions since y is complex. At a = 1, the number of equilibrium solutions changes from 2 to 1 to 0, as the value of parameter a goes from a<1 to 1 to a>1. Therefore a = 1 is a bifurcation point (and is the only bifurcation point since the number of equilibrium solutions doesn't change at any other value of a). For more details about this example, see Section 2.4 Bifurcation in LibreText MTH 225 Differential Equations. Summarizing, using the quadratic formula in symbolic form gave the equilibria and bifurcation points to a nonlinear ODE -- not bad for a useless formula! :) Nonlinear ODEs are everyday staples for engineers working with MEMS and NEMS sensors and nonlinear control, for brain neuroscientists, applied mathematicians, and on and on. While all of us can make it through dinner without using the quadratic formula, many would be unable to get through a day without it! :) |
|||
Yesterday, 02:27 PM
(This post was last modified: Yesterday 08:39 PM by Albert Chan.)
Post: #54
|
|||
|
|||
RE: Mathematician Finds Easier Way to Solve Quadratic Equations
(05-04-2024 02:24 PM)Albert Chan Wrote: For acosh √(z²-1) form, we need to match sign, to ensure non-negative real part. Trivia, RHS ensured *both* complex parts without cancellation issue. Kahan's csqrt(z = x+y*i) formula: √(z) = √((|z|+x)/2) + sign(y) * √((|z|-x)/2) * i Let sign(z) = [sign(x), sign(y)] (z²-1) = (x²-y²-1) + (2*x*y) * i sign(x) * sign(√(z²-1)) = sign(x) * [1, sign(x*y)] = sign(z) (Yesterday 02:32 AM)Albert Chan Wrote: x1 = -p/2 + √Δ Sorry, test with sign(Re(p)) may not get the big root. Example, x² - 2m + m = 0, where m = 0.1 + 100*I, s = sign(Re(m)) = 1 m + s * √(m²-m) ≈ (0.1+100*I) + (0.399995-100.001*I) = (0.499995-0.001*I) This get the wrong smaller root, massive cancellation of imag part. KISS is not simple. Hyp/Trig versions are better. z = GM/AM = √(q)/(-p/2) = √(m)/m x1 = √(q) * e^acosh(1/z) ≈ √(0.1+100*I) * (14.1139+14.1705*I) ≈ (-0.299995+200.001*I) x1 = m + m*cos(asin(z)) ≈ (0.1+100*I) + (-0.399995+100.001*I) ≈ (-0.299995+200.001*I) x2 = q/x1 ≈ (0.499995-0.00124997*I) Or, go straight for small root, without massive cancellation: x2 = √(q) / e^acosh(1/z) ≈ (0.499995-0.00124997*I) x2 = -p * sin(asin(z)/2)^2 ≈ (0.499995-0.00124997*I) |
|||
Yesterday, 06:22 PM
Post: #55
|
|||
|
|||
RE: Mathematician Finds Easier Way to Solve Quadratic Equations
(Yesterday 02:27 PM)Albert Chan Wrote: Example, x² - 2m + m = 0, where m = 0.1 + 100*I, s = sign(Re(m)) = 1Not that bad for this particular example. I still get -0.001249972i on the 42S, all the rest being exactly the same. If I insert a +/- instruction after SQRT, then I get the full -0.00124997218867. This choice of the most favorable first root might be done programmatically, but that would cost some extra bytes and steps. (Yesterday 02:27 PM)Albert Chan Wrote: Hyp/Trig versions are better.Yes, depending on what is our goal. Perhaps that lightbulb is worth changing, no matter how many of us it takes. The other option is living forever in the dark. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)