cubic {AlgebraicHaploPackage} R Documentation

## Function that can resolve the cubic equation numerical stable and any lower dimensional case except unsolvable cases.

### 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

```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,output,output. 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.

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

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