From f1a6a8e5867b86255f1144f7572f5b28357df2b1 Mon Sep 17 00:00:00 2001 From: hugogogo Date: Fri, 15 May 2026 02:51:42 +0200 Subject: [PATCH] change output to use discriminant instead of radicant --- src/printer_solutions.c | 6 +++--- tester.sh | 36 ++++++++++++++++++------------------ 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/printer_solutions.c b/src/printer_solutions.c index 5bc1755..58d479c 100644 --- a/src/printer_solutions.c +++ b/src/printer_solutions.c @@ -18,7 +18,7 @@ static void print_solution_degree_1(s_solution_degree_1 solution) static void print_solution_pure_radicand_zero() { - ft_printf("Radicant is equal to zero, the solution is:\n"); + ft_printf("Discriminant is equal to zero, the solution is:\n"); printf("0\n"); } @@ -27,7 +27,7 @@ static void print_solution_pure_radicand_positiv(s_solution_degree_2_pure soluti double numerator; double denominator; - ft_printf("Radicant is strictly positive, the two solutions are:\n"); + ft_printf("Discriminant is strictly positive, the two solutions are:\n"); if (solution.numerator_sqrt_is_int && solution.denominator_sqrt_is_int) { numerator = solution.numerator_sqrt; @@ -77,7 +77,7 @@ static void print_solution_pure_radicand_negativ(s_solution_degree_2_pure soluti double numerator; double denominator; - ft_printf("Radicant is strictly negative, the two complex solutions are:\n"); + ft_printf("Discriminant is strictly negative, the two complex solutions are:\n"); if (solution.numerator_sqrt_is_int && solution.denominator_sqrt_is_int) { numerator = solution.numerator_sqrt; diff --git a/tester.sh b/tester.sh index e3d97be..11c109c 100644 --- a/tester.sh +++ b/tester.sh @@ -134,20 +134,20 @@ run_test() { run_test \ "1. degree 2" \ "3 * x^2 + 5 * x^1 - 2 * x^0 = 5 * x^1" "\ -Reduced form: 2 * x^0 + 0 * x^1 + 3 * x^2 = 0 +Reduced form: -2 * x^0 + 0 * x^1 + 3 * x^2 = 0 Polynomial degree: 2 -Discriminant is strictly negative, the two complex solutions are: --√(2/3) -√(2/3)" +Discriminant is strictly positive, the two solutions are: +√(2/3) +-√(2/3)" run_test \ "2. degree 2" \ "3.4 * x^2 + 1 * x^1 - 2.0 * x^0 = 5 * x^1" "\ -Reduced form: 2 * x^0 - 4 * x^1 + 3.4 * x^2 = 0 +Reduced form: -2 * x^0 - 4 * x^1 + 3.4 * x^2 = 0 Polynomial degree: 2 -Discriminant is strictly negative, the two complex solutions are: -4/6.8 + 3.34664i/6.8 -4/6.8 - 3.34664i/6.8" +Discriminant is strictly positive, the two solutions are: +1.5548 +-0.378334" run_test \ "3. degree 2" \ @@ -155,8 +155,8 @@ run_test \ Reduced form: 0 * x^0 - 5 * x^1 + 5 * x^2 = 0 Polynomial degree: 2 Discriminant is strictly positive, the two solutions are: -13 --12" +1 +0" run_test \ "4. flag -e" \ @@ -271,7 +271,7 @@ run_test \ "3x² + x -0 = x" "\ Reduced form: 0 * x^0 + 0 * x^1 + 3 * x^2 = 0 Polynomial degree: 2 -Radicant is equal to zero, the solution is: +Discriminant is equal to zero, the solution is: 0" run_test \ @@ -322,7 +322,7 @@ run_test \ "3x^2 = 0" "\ Reduced form: 0 * x^0 + 0 * x^1 + 3 * x^2 = 0 Polynomial degree: 2 -Radicant is equal to zero, the solution is: +Discriminant is equal to zero, the solution is: 0" run_test \ @@ -330,7 +330,7 @@ run_test \ "3x^2 + 2 = 0" "\ Reduced form: 2 * x^0 + 0 * x^1 + 3 * x^2 = 0 Polynomial degree: 2 -Radicant is strictly negative, the two complex solutions are: +Discriminant is strictly negative, the two complex solutions are: i√(2/3) -i√(2/3)" @@ -339,7 +339,7 @@ run_test \ "3 * x^2 + 5 * x^1 - 2 * x^0 = 5 * x" "\ Reduced form: -2 * x^0 + 0 * x^1 + 3 * x^2 = 0 Polynomial degree: 2 -Radicant is strictly positive, the two solutions are: +Discriminant is strictly positive, the two solutions are: √(2/3) -√(2/3)" @@ -348,7 +348,7 @@ run_test \ "9 * x^2 + 5 * x^1 - 2 * x^0 = 5 * x" "\ Reduced form: -2 * x^0 + 0 * x^1 + 9 * x^2 = 0 Polynomial degree: 2 -Radicant is strictly positive, the two solutions are: +Discriminant is strictly positive, the two solutions are: √(2)/3 -√(2)/3" @@ -357,7 +357,7 @@ run_test \ "3 * x^2 + 5 * x^1 - 4 * x^0 = 5 * x" "\ Reduced form: -4 * x^0 + 0 * x^1 + 3 * x^2 = 0 Polynomial degree: 2 -Radicant is strictly positive, the two solutions are: +Discriminant is strictly positive, the two solutions are: 2/√(3) -2/√(3)" @@ -366,7 +366,7 @@ run_test \ "16 * x^2 + 5 * x^1 - 4 * x^0 = 5 * x" "\ Reduced form: -4 * x^0 + 0 * x^1 + 16 * x^2 = 0 Polynomial degree: 2 -Radicant is strictly positive, the two solutions are: +Discriminant is strictly positive, the two solutions are: 1/2 -1/2" @@ -375,7 +375,7 @@ run_test \ "4 * x^2 + 5 * x^1 - 16 * x^0 = 5 * x" "\ Reduced form: -16 * x^0 + 0 * x^1 + 4 * x^2 = 0 Polynomial degree: 2 -Radicant is strictly positive, the two solutions are: +Discriminant is strictly positive, the two solutions are: 2 -2"