gitee.com/quant1x/num@v0.3.2/polynomial_test.go (about) 1 package num 2 3 import ( 4 "fmt" 5 "testing" 6 ) 7 8 func Test_PolyVal(t *testing.T) { 9 x := []float64{0.0, 0.1, 0.2, 0.3, 0.5, 0.8, 1.0} 10 y := []float64{1.0, 0.41, 0.50, 0.61, 0.91, 2.02, 2.46} 11 A := PolyFit(x, y, 2) 12 fmt.Println(A) 13 14 //A2 := []float64{3.131561350718812, -1.2400367769976413, 0.7355767301905694} 15 z1 := PolyVal(A, x) 16 fmt.Println(z1) 17 18 W := 5 19 A2 := PolyFit(y, Range[float64](W), 1) 20 x2 := Repeat[float64](float64(W), W) 21 z2 := PolyVal(A2, x2) 22 fmt.Println(z2) 23 }