-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCubic.java
More file actions
25 lines (19 loc) · 740 Bytes
/
Cubic.java
File metadata and controls
25 lines (19 loc) · 740 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
public class Cubic extends Formula
{
public Cubic( double[] params )
{
super( params );
}
public Cubic( Double[] x, Double[] y )
{
super( backSolve( new double[][] {
{ x.length, sigma( x ), sigma( x, 2.0 ), sigma( x, 3.0 ), sigma( y ) },
{ sigma( x ), sigma( x, 2.0 ), sigma( x, 3.0 ), sigma( x, 4.0 ), sigma( x, y ) },
{ sigma( x, 2.0 ), sigma( x, 3.0 ), sigma( x, 4.0 ), sigma( x, 5.0 ), sigma( x, y, 2.0 ) },
{ sigma( x, 3.0 ), sigma( x, 4.0 ), sigma( x, 5.0 ), sigma( x, 6.0 ), sigma( x, y, 3.0 ) } } ) );
}
public double getY( double x )
{
return Params[0] + Params[1] * x + Params[2] * x * x + Params[3] * x * x * x;
}
}