improve printer
This commit is contained in:
25
src/solver.c
25
src/solver.c
@@ -34,27 +34,10 @@ static void solve_degree_2(s_solution_degree_2 *solution, double a, double b, do
|
||||
delta_sqrt = solution->delta_sqrt;
|
||||
|
||||
// terms
|
||||
solution->first_term = positiv_zero(-b / (2 * a)); // -b / 2a
|
||||
solution->second_term = positiv_zero(delta_sqrt / 2 * a); // √|Δ| / 2a
|
||||
|
||||
// solution
|
||||
solution->solution1 = solution->first_term; // first_term + second_term
|
||||
if (solution->delta_sign == DELTA_ZERO)
|
||||
{
|
||||
solution->solution1 = positiv_zero(solution->first_term); // -b / 2a
|
||||
solution->solution2 = NAN; // NAN (no solution)
|
||||
}
|
||||
else if (solution->delta_sign == DELTA_PLUS)
|
||||
{
|
||||
solution->solution1 = positiv_zero(solution->first_term + solution->second_term); // -b / 2a + √Δ / 2a
|
||||
solution->solution2 = positiv_zero(solution->first_term - solution->second_term); // -b / 2a - √Δ / 2a
|
||||
}
|
||||
else if (solution->delta_sign == DELTA_MINUS)
|
||||
{
|
||||
// no real solution, but can output irreal solution with 'i'
|
||||
solution->solution1 = NAN;
|
||||
solution->solution2 = NAN;
|
||||
}
|
||||
if (b)
|
||||
solution->first_term = positiv_zero(-b / (2 * a)); // -b / 2a
|
||||
if (delta)
|
||||
solution->second_term = positiv_zero(delta_sqrt / 2 * a); // √|Δ| / 2a
|
||||
}
|
||||
|
||||
void solve(const s_polynom *polynom, s_solution *solution)
|
||||
|
||||
Reference in New Issue
Block a user