Alternatives
Members may post updates or alternatives to this current article in order to show different
approaches or add new features.
1. A simple program to solve quadratic equations with
Updated: 16 Nov 2010
I prefer this :) #include #include #include #include static const double bad_double = std::numeric_limits::quiet_NaN();class QuadSolver{ static bool IsZero(double val) { return (val == 0) || (fabs(val) <...
C++
|
|
|
|
2. A simple program to solve quadratic equations with
Updated: 9 Nov 2010
// Real solutions of the quadratic equation A x^2 + B x + C = 0// Returns two roots (possibly identical) in increasing order, or nonebool Quadratic(double A, double B, double C, double R[2]){ if (A == 0) { // Linear, impossible or degenerate, cannot find two roots ...
C++
|
|
|
|
3. A simple program to solve quadratic equations with
Updated: 10 Nov 2010
The correct way to solve quadratic equations is none of the above. For the correct algorithm as applied in the following function, seenumerical recipes in C and the Wolfram site at http://mathworld.wolfram.com/QuadraticEquation.html#include bool quadratic(double a, double b,...
C++
|
|
|
|
4. A simple program to solve quadratic equations with
Updated: 20 May 2010
#include #include #include "Raiz_Cuadratica.h"int main(){ // float xx = 1; float x = 1; float i = -12; RaizCuadratica *lala = new RaizCuadratica( xx, x, i ); RaizCuadratica::sRaiz raiz = lala->GetRaiz(); printf( "x1 = %f || x2 = %f\n\n",...
C++
|
|
|
|
5. A simple program to solve quadratic equations with
Updated: 11 Nov 2010
A simple program to calculate quadratic equation with.Input MUST have the format:AX2 + BX + C = 0EXAMPLE: input the equation 2X2 + 4X -30 = 0 as:A= 2 B= 4 C= -30The answers for AX2 + BX + C = 0 should be 3 and -5.x1=3x2=-5 bool solver(float...
C++
|
|
|
|
6. A simple program to solve quadratic equations with
Updated: 7 Nov 2010
#include
C++
|
|
|
|
7. A simple program to solve quadratic equations with
Updated: 15 Nov 2010
I am reposting this because I accidentally deleted my first post.The solution is presented as a pair of complex roots, unless a == 0, in which case the equation is linear and returns a single complex(real) root.If a == 0 and b == 0, the function fails.Given a complex type, replace...
C++
|
|
|
|