cubic {AlgebraicHaploPackage} | R Documentation |
A*x^3+B*x^2+C*x+D=0. All coefficients had to be numeric or integers. This function calculates from 4 coefficient all possible and senfully solutions. D=0 returns no values at all. This would be a impossibel case. It returns upto 3 potential complex solutions. Less solutions are copied to get the tripple solution format.
cubic(A, B, C, D)
A |
The coefficient of x^3. |
B |
The coefficient of x^2. |
C |
The coefficient of X. |
D |
The constant. |
This function is called by haplotypeit. The results are returned as vector of the three possible solutions: output[1],output[2],output[3]. Further data for checks of the roots. p,q and the discriminat. 10 and 11 are only usable for symmetry checks.
Returns cubic
(A,B,C,D)[c(1:3)] roots of the at most cubic equation.
Using cardenian formular, a well known method.
Jan Wolfertz
Cardans formular as in e.g. The Mathematical Gazette (1993); 77 (Nov, No 480), 354-359 (jstor) http://www.nickalls.org/dick/papers/maths/cubic1993.pdf or any other book for algebraic solutions. See also : http://de.wikipedia.org/wiki/Cardanische_Formeln and http://en.wikipedia.org/wiki/Cubic_equation
haplotypeit,callhaplotype
cubic(1,0,0,-1)[c(1:3)] cubic(1,1,0,0)[c(1:3)]