@@ -30,6 +30,32 @@ async def squareroot(self, ctx: ApplicationContext, number: int):
30
30
localembed = discord .Embed (title = f"Square root of { number } " , description = result , color = color )
31
31
localembed .set_footer (text = f"√({ number } ) = { result } " )
32
32
await ctx .respond (embed = localembed )
33
+
34
+ @math .command (
35
+ name = "solve_quadratic_roots" ,
36
+ description = "Find the (real) root(s) of a quadratic equation/function."
37
+ )
38
+ @option (name = "coeff_a" , description = "Coefficient 'a' of the equation" , type = int )
39
+ @option (name = "coeff_b" , description = "Coefficient 'b' of the equation" , type = int )
40
+ @option (name = "coeff_c" , description = "Coefficient 'c' of the equation" , type = int )
41
+ async def math_solve_quadratic_roots (self , ctx : ApplicationContext , coeff_a : int , coeff_b : int , coeff_c : int ):
42
+ """Find the (real) root(s) of a quadratic equation/function."""
43
+ # First finding discrim of Q.E
44
+ a = coeff_a
45
+ b = coeff_b
46
+ c = coeff_c
47
+ discrim = (b ^ 2 ) - 4 * a * c
48
+ if discrim >= 0 :
49
+ root_1 = (- b * sqrt ((b ^ 2 ) - 4 * a * c ))/ 2 * a
50
+ root_2 = (- b * - sqrt ((b ^ 2 ) - 4 * a * c ))/ 2 * a
51
+ result = f"The roots of the quadratic equation are:\n - **Root 1:** { root_1 } ``\n - **Root 2:** { root_2 } ``\n \n ```Equation:\n \n f(x) = { a } x² + { b } x + { c } = 0```"
52
+ else :
53
+ result = "The roots of the quadratic equation are imaginary."
54
+ localembed = discord .Embed (
55
+ title = f"Roots of the Quadratic Equation **{ a } x² + { b } x + { c } = 0**" ,
56
+ description = result
57
+ )
58
+ ctx .respond (embed = localembed )
33
59
34
60
@math .command (
35
61
name = "area_square" ,
0 commit comments