Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Task 1 : Absolute Difference between roots of Quadratic equations [ 3 0 marks ] There are many kinds of equations to solve in algebra.

Task 1: Absolute Difference between roots of Quadratic equations [30 marks]
There are many kinds of equations to solve in algebra. One of the most common kind of equations are
quadratic equations, which come in the form of ax2+bx+c=0, where x is the variable, and a,b and c
are the coefficients of the equation. In 628AD, Brahmagupta explicitly described the general formula to be:
x=-b+-b2-4ac22a
Assuming that b24ac holds, the equation will have two real roots (which might be equal).
You are given an incomplete code for a Python function rootAbsDiff ) that takes in the three
coefficients a,b, and c of a quadratic equation. You may assume that rootAbsDiff is always called with the
three coefficients such that b24ac. Every time when it is called, rootAbsDiff calculates the two roots of
the equation and returns the absolute difference between the two roots.
You may use the sqrt function from the math library to help you calculate square roots. You might also
use the abs function (which is a built-in function in Python to help you calculate absolute values.)
Complete the definition of rootAbsDiff, and test its correctness in Python shell, as follows:
rootAbsDiff(1,2,1)
0.0
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started