write a program functionprocedurescript to solve problem b

write a program (function,procedure,script ) to solve problem , by using any program like ( matlab , python.... )

Code a function to solve the second-order differential equation ay\" + by\' + cy = 0. Your function should have three arguments (a, b, c). Suppose your function is EQSOL(a, b, c), then you need to run the following examples. EQSOL(l, 4, 4); EQSOL(l, -5, G), and EQSOL(l, 2, 5).

Solution

def EQSOL(a,b,c):
disc= (b*b) - (4 * a * c)
if disc>0:
r1= (-b + (b*b - 4 * a * c)**0.5) / (2*a)
r2= (-b - (b*b - 4 * a * c)**0.5) / (2*a)
print (\"Display two roots\",r1, r2)
elif disc==0:
r1= (-b + (b*b - 4 * a * c)**0.5) / (2*a)
r2= (-b - (b*b - 4 * a * c)**0.5) / (2*a)
print (\"Display one root\", r1)
else:
print (\"The equation has no real roots\")


EQSOL(1,4,4)
EQSOL(1,-5,6)
EQSOL(1,2,5)

write a program (function,procedure,script ) to solve problem , by using any program like ( matlab , python.... ) Code a function to solve the second-order diff

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site