예제 #1
0
func testExp0(n float64) {
	nn := make([]float64, 1)
	nn[0] = n
	answer, errbnd := vecQuad.IntegralCalcConcurrent(SimpleExp, &nn, 1)
	fmt.Println("Integral of 1/Exp(x) from 0 to inf =", answer)
	fmt.Println("Actual result should be =", math.Exp(-n))
	fmt.Println("Error of integral =", errbnd)
}
예제 #2
0
func testExp4(n, m float64) {
	LimitsList := make([]float64, 2)
	LimitsList[0], LimitsList[1] = n, m
	answer, errbnd := vecQuad.IntegralCalcConcurrent(SimpleQuadr, &LimitsList, 1)
	fmt.Println("Integral of x^2 from ", n, " to ", m, " =", answer[0])
	fmt.Println("Actual result should be =", float64(1.0/3.0)*(m*m*m-n*n*n))
	fmt.Println("Error of integral =", errbnd)
}
예제 #3
0
func testExp5(n, m float64) {
	LimitsList := make([]float64, 2)
	LimitsList[0], LimitsList[1] = n, m
	answer, errbnd := vecQuad.IntegralCalcConcurrent(VectorizedFunc2, &LimitsList, 2)
	fmt.Println("Integral of x^2 from ", n, " to ", m, " =", answer[0])
	fmt.Println("Actual result should be =", float64(1.0/3.0)*(m*m*m-n*n*n))
	fmt.Println("Error of first integral =", errbnd[0])
	fmt.Println("Integral of 3*x from ", n, " to ", m, " =", answer[1])
	fmt.Println("Actual result should be =", float64(1.5)*(m*m-n*n))
	fmt.Println("Error of second integral =", errbnd[1])
}
예제 #4
0
func testExp1(n float64) {
	nn := make([]float64, 1)
	nn[0] = n
	answer, errbnd := vecQuad.IntegralCalcConcurrent(VectorizedFunc0, &nn, 2)
	fmt.Println("Integral of 1/Exp(x) from 0 to inf =", answer[0])
	fmt.Println("Actual result should be =", math.Exp(-n))
	fmt.Println("Error of first integral =", errbnd[0])
	fmt.Println("Integral of 1/Exp(2*x) from 0 to inf =", answer[1])
	fmt.Println("Actual result should be =", float64(0.5)*math.Exp(-2.0*n))
	fmt.Println("Error of second integral =", errbnd[1])
}
예제 #5
0
func testExp6(n, m float64) {
	LimitsList := make([]float64, 2)
	LimitsList[0], LimitsList[1] = n, m
	answer, errbnd := vecQuad.IntegralCalcConcurrent(VectorizedFunc3, &LimitsList, 4)
	fmt.Println("Integral of 1/Exp(x) from ", n, " to ", m, " =", answer[0])
	fmt.Println("Actual result should be =", math.Exp(-1.0*n)-math.Exp(-1.0*m))
	fmt.Println("Error of first integral =", errbnd[0])
	fmt.Println("Integral of 2*x from ", n, " to ", m, " =", answer[1])
	fmt.Println("Actual result should be =", (m*m - n*n))
	fmt.Println("Error of second integral =", errbnd[1])
	fmt.Println("Integral of x^3 from ", n, " to ", m, " =", answer[2])
	fmt.Println("Actual result should be =", float64(0.25)*(m*m*m*m-n*n*n*n))
	fmt.Println("Error of third integral =", errbnd[2])
	fmt.Println("Integral of 1/Exp(2*x) from ", n, " to ", m, " =", answer[3])
	fmt.Println("Actual result should be =", float64(0.5)*(math.Exp(-2.0*n)-math.Exp(-2.0*m)))
	fmt.Println("Error of fourth integral =", errbnd[3])
}
예제 #6
0
func testExp2(n float64) {
	nn := make([]float64, 1)
	nn[0] = n
	answer, errbnd := vecQuad.IntegralCalcConcurrent(VectorizedFunc1, &nn, 4)
	fmt.Println("Integral of 1/Exp(x) from 0 to inf =", answer[0])
	fmt.Println("Actual result should be =", math.Exp(-1.0*n))
	fmt.Println("Error of first integral =", errbnd[0])
	fmt.Println("Integral of 1/Exp(2*x) from 0 to inf =", answer[1])
	fmt.Println("Actual result should be =", 0.5*math.Exp(-2.0*n))
	fmt.Println("Error of second integral =", errbnd[1])
	fmt.Println("Integral of 1/(Exp(0.5*x*x) * Sqrt(2.0*Pi)) from 0 to inf =", answer[2])
	fmt.Println("Actual result should be =", float64(0.5))
	fmt.Println("Error of third integral =", errbnd[2])
	fmt.Println("Integral of 1/Exp(3*x) from 0 to inf =", answer[3])
	fmt.Println("Actual result should be =", float64(1.0/3.0)*math.Exp(-3.0*n))
	fmt.Println("Error of fourth integral =", errbnd[3])
}