Solving Quadratic Equations and Reciprocals in Python
Problem 1: Finding the Roots of a Quadratic Equation
Quadratic equations are fundamental in algebra and are often represented as:
[ ax^2 + bx + c = 0 ]
To find the roots of a quadratic equation, I used the quadratic formula:
[ x = \frac{-b \pm \sqrt{b^2 – 4ac}}{2a} ]
In this example, I solved the quadratic equation:
[ x^2 – 5.86x + 8.5408 = 0 ]
Here, the coefficients are ( a = 1 ), ( b = -5.86 ), and ( c = 8.5408 ).
First, I calculated the discriminant (( \Delta )):
[ \Delta = b^2 – 4ac ]
Next, I used the quadratic formula to find the roots:
[ x = \frac{-(-5.86) \pm \sqrt{(-5.86)^2 – 4 \cdot 1 \cdot 8.5408}}{2 \cdot 1} ]
Here’s the Python code to compute this:

After running the code, I found the roots are approximately:
- Root 1: 3.14
- Root 2: 2.72
Problem 2: Printing Reciprocals
The next problem involves printing the decimal representations of the reciprocals of numbers from 2 to 10. The reciprocal of a number ( n ) is given by ( \frac{1}{n} ).
I achieved this by using a for loop in Python:

Running this code produced the following output:
- ( 1/2 = 0.5 )
- ( 1/3 = 0.3333 )
- ( 1/4 = 0.25 )
- ( 1/5 = 0.2 )
- ( 1/6 = 0.1667 )
- ( 1/7 = 0.1429 )
- ( 1/8 = 0.125 )
- ( 1/9 = 0.1111 )
- ( 1/10 = 0.1 )
Conclusion
In this assignment, I solved a quadratic equation to find its roots and printed the reciprocals of numbers from 2 to 10 using Python. These exercises demonstrate the power and simplicity of Python for mathematical computations.
Leave a comment