(15C) Quadratic Equation
|
07-30-2021, 03:46 PM
(This post was last modified: 10-24-2022 07:37 AM by C.Ret.)
Post: #2
|
|||
|
|||
RE: (15C) Quadratic Equation
Please let me share here an evolution of the previous code.
This new version of the solver find any roots of the Quadratic Equation of \( a.x^2 + b.x + c = 0 \) where the three coefficients \( a \) ,\( b \) and \( c \) are any real or complex numbers. Consequently, the two roots are real or complex number as well and not necessary conjugates. The usage of this new version is expressly the same as the version posted by Gamo. Code: Code: 001- 2 2 012- 36 ENTER Out: Y: x2 X: z1 Register: none Flags: Flag 8 is set when any root x1 or x2 is complex. Usage: Enter the three coefficients in the order \( a \), \(b\) and \(c\) where \(a\) can't be zero. Run the code by pressing the [R/S] key. You may have to add a user label at the beginning of this short code if it's sharing the program memory space with any other code. The roots of the corresponding quadratic polynomial are computed and stored in stack at X: and Y:. No memory register is used or affected by the run of this code. If one of the two roots is complex, the 'c' annunciator is lit on at the bottom of the display. it's a good practice to clear Flag_8 (complex mode indicator) before entering real coefficients, so that the appearing of the 'c' annunciator indicate that there is no real root. But this is in no way mandatory. Entering a complex number automaticaly set the flag 8 to activate the complex stack and computations. To see the complex part press and hold f[(i)]. If the complex 'c' annunciators is off and no imaginary part exist then Error 3 occurs. To see the other root press [X↔Y] key. this will give you positive and negative complex answer. Example 1 integer coefficients : \( 108x^2+1188x-140616 = 0 \) Optionally, since no coefficient is a complex number, you may clear Complex Mode : g[CF][ 8 ] Enter a: [ 1 ][ 0 ][ 8 ][ENTER] Enter b: [ 1 ][ 1 ][ 8 ][ 8 ][ENTER] Enter c: [ 1 ][ 4 ][ 0 ][ 6 ][ 1 ][ 6 ][CHS] Press [R/S] to run code and display the first root: " 31.00000 " Press [X↔Y] to display the second root: "-42.00000 " The roots of the quadratic equation \( 108x^2+1188x-140616 = 0 \) are the two integers \(31\) and \(-42\). Example 2 number coefficients : \( 5x^2-51.2x+131.072 = 0 \) Optionally, since no coefficient is a complex number, you may clear Complex Mode : g[CF][ 8 ] Enter a: [ 5 ][ENTER] Enter b: [ 5 ][ 1 ][ . ][ 2 ][CHS][ENTER] Enter c: [ 1 ][ 3 ][ 1 ][ . ][ 0 ][ 7 ][ 2 ] Press [R/S] to run code and display the first root: " 5.12000 " Press [X↔Y] to display the second root: " 5.12000 " (double root here !) The quadratic equation \( 5x^2-51.2x+131.072 = 0 \) admit a double root \( x_1=x_2=5.12 \) Example 3 integer coefficients and complex conjugate roots : \( x^2-4x+13 = 0 \) Optionally, since no coefficient is a complex number, you may clear Complex Mode : g[CF][ 8 ] Enter a: [ 1 ][ENTER] (entering a non zero a coefficient is mandatory) Enter b: [ 4 ][CHS][ENTER] Enter c: [ 1 ][ 3 ] Press [R/S] to run code and notice that the 'c' annunciator is displayed indicating complex roots: Real part of first root is on display " 2.00000 " Press and hold f[(i)] key to see imaginary part of first root: " 3.00000 " Press [X↔Y] to display the second root real part : " 2.00000 " Press and hold f[(i)] to display the second root’s imaginary part: "-3.00000 " The two roots of quadratic equation \( z^2-4z+13 = 0 \) are the conjugates \(z_1=2+3i\) and \(z_2=2-3i=\bar{z_1}\) Example 4 full complex example : \( (2+3i).z^2+(-6-87i).z+(-483+1193i) = 0 \) Enter a: [ 2 ][ENTER] [ 3 ] f[ I ] (note that the 'c' annunciators lit on) Enter b: [ 6 ][CHS][ENTER] [ 8 ][ 7 ][CHS] f[ I ] Enter c: [ 4 ][ 8 ][ 7 ][CHS][ENTER] [ 1 ][ 1 ][ 9 ][ 3 ] f[ I ] Press [R/S] to run code. Real part of first root is " 17.00000 " Press and hold f[(i)] key to see imaginary part of first root: "-7.00000 " Press [X↔Y] to display the second root real part : " 4.00000 " Press and hold f[(i)] to display the second root’s imaginary part: " 19.00000 " The two roots of quadratic equation \( (2+3i).z^2+(-6-87i).z+(-483+1193i) = 0 \) are the complex \(z_1=17-7i\) and \(z_2=4+19i \) Example 5 mixte example : \( (3-i).z^2+(-49+33i).z+120-90i = 0 \) Enter a: [ 3 ][ENTER] [ 1 ][CHS] f[ I ] (note that the 'c' annunciators lit on) Enter b: [ 4 ][ 9 ][CHS][ENTER] [ 3 ][ 3 ] f[ I ] Enter c: [ 1 ][ 2 ][ 0 ][ENTER] [ 9 ][ 0 ][CHS] f[ I ] Press [R/S] to run code. Real part of first root is " 15.00000 " Press and hold f[(i)] key to see imaginary part of first root: "-5.00000 " Press [X↔Y] to display the second root real part : " 3.00000 " Press and hold f[(i)] to display the second root’s imaginary part: " 0.00000 " The quadratic equation \( (3-i).z^2+(-49+33i).z+120-90i = 0 \) have one complex root \(z_1=15-5i\) and one real root \(x_2=3 \) |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
(15C) Quadratic Equation - Gamo - 06-29-2018, 12:20 PM
RE: (15C) Quadratic Equation - C.Ret - 07-30-2021 03:46 PM
|
User(s) browsing this thread: 1 Guest(s)