cubic: Function that can resolve the cubic equation numerical stable...

Description Usage Arguments Details Value Note Author(s) References See Also Examples

View source: R/AlgebraicHaplo.R

Description

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.

Usage

1
cubic(A, B, C, D)

Arguments

A

The coefficient of x^3.

B

The coefficient of x^2.

C

The coefficient of X.

D

The constant.

Details

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.

Value

Returns cubic(A,B,C,D)[c(1:3)] roots of the at most cubic equation.

Note

Using cardenian formular, a well known method.

Author(s)

Jan Wolfertz

References

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

See Also

haplotypeit,callhaplotype

Examples

1
2
cubic(1,0,0,-1)[c(1:3)]
cubic(1,1,0,0)[c(1:3)]

AlgebraicHaploPackage documentation built on May 29, 2017, 9:12 p.m.