Question: (JAVA) Can someone help me get this code right please. The true answer of the result should be 0.3430. When I test the function I'm

(JAVA) Can someone help me get this code right please. The true answer of the result should be 0.3430. When I test the function I'm getting wrong answers. For f(x1) it should be 0.9615, for f(x2) it should be 0.9174, etc. but I'm getting erroneous answers.

(JAVA) Can someone help me get this code right please. The true

******** ************** public class NumericalQuadrature { + /**...3 lines */ // functions public static double f(double x) return 1.0 / 1.0 + x * x; public static void main(String[] args) { // Closed Newton Cotes method double a = 0.27 double b-0.6; double n = 4.0; double h = (b double x1 - a; double x2 = x1 + hi double x3 = x2 + h; double x4 x3 + h: double x5 = x4 + hi double result = (float)2.0 / 45.0 * h (7.0 * f(x1) + 32.0 * f(x2) + 12.0 + f(x3) + 32.0 + f(x4) + 7.0 * f(x5)); //System.out.println("For the function = 1 - sin(1-x):"); System.out.println("Weights = 7, 32, 12, 32, 7"); System.out.printf("Nodes - 4.1f, .1f, *.1f, 6.15, 4.1f ", x1,x2, x3, 34, 35); System.out.println(result); System.out.println(); // testing the function for correctness System.out.println(f(x1)); System.out.println(f(x2)); System.out.println(f(x3)); System.out.println(f(x4)); System.out.println(f(x5)); ) umericalquadrature.NumericalQuadrature> main > Delete Project x NumericalQuadrature (run) x ant -I C:\\Users\\dark_\\Documents\\NetBeans Projects\\NumericalOuadrature - Dnb.internal action came-run run init: Deleting: c:\Users\dark_\Documents\NetBeans Projects\NumericalQuadrature\build\built-jar.properties deps-jar: Updating property file: C:\Users\dark_\Documents\NetBeans Projects Numerical quadrature\build built-jar.properties Compiling 1 source file to C:\Users\dark_\Documents\NetBeans Projects Numerical Quadrature build classes compile: F11 Weights - 7, 32, 12, 32, 7 Nodes = 0.2, 0.3, 0.4, 0.5, 0.6 0.4693333333333333 1.09 1.16 1.25 1.3599999999999999 BUILD SUCCESSFUL (total time: 0 seconds) 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!