2c md-eqn code

  • Roots of y=ax2+bx+cy = ax^2 + bx + c can be obtained from x1,2=b±D2a. x_{1,2} = \frac{-b \pm \sqrt{D}}{2a}.
  • Discriminant D=b24cD = b^2 - 4c.
a = 1
b = -9.5
c = 15

D = b**2 - 4*a*c
x1 = (-b - D**0.5) / (2*a)
x2 = (-b + D**0.5) / (2*a)

print('x1 =', x1)
print('x2 =', x2)
dudung, OneCompiler, 28 Dec 2024, https://onecompiler.com/python/434bxmyz4 [20241228].