# Newton Cotes, Gaussian, and quadrature methods in Java assignment help

The assignment deals with evaluating the closed Newton Cotes, Gaussian, and quadrature methods using 3 different functions, it displays the quadrature results, weights, and nodes used on the console. Below is Newton Cotes, Gaussian, and quadrature methods demonstrated by our Java assignment help providers.
``` /* * PURPOSE: Evaluatestheclosed Newton Cotes, Gaussian and Lobatto * quadraturemethodsusing 3 differentfunctions, displaysthequadrature * results, weights and nodesused * OUTPUT: Printsallquadratureresultsonthescreen. */ publicclassQuadrature { /** * PURPOSE: Definitionofthefirstfunctionto use in thequadratures * INPUT: x, position in X usedtoevaluatefunction * OUTPUT: double, evaluationofthefirstfunction in X. */ publicstaticdouble function1(double x) { return 1 - Math.sin(1 - x); } /** * PURPOSE: Definitionofthesecondfunctionto use in thequadratures * INPUT: x, position in X usedtoevaluatefunction * OUTPUT: double, evaluationofthefirstfunction in X. */ publicstaticdouble function2(double x) { returnMath.sqrt(x + 1) + 1; } /** * PURPOSE: Definitionofthethirdfunctionto use in thequadratures * INPUT: x, position in X usedtoevaluatefunction * OUTPUT: double, evaluationofthefirstfunction in X. */ publicstaticdouble function3(double x) { returnMath.tanh(x + 1); } /** * PURPOSE: Evaluatethequadratureofthe 3 functionsdefinedaboveusing * theclosed Newton Cotes quadrature * INPUT: None * OUTPUT: printsthequadratureresultsonthescreen. */ publicstaticvoidnewtonCotes() { int n = 5; // use 5 points double x0 = -1; // lowerlimit doublexn = 1; // upperlimit double h = (xn - x0)/n; // step size double w [] = { // weights 19./288., 25./96., 25./144., 25./144., 25./96., 19./288. }; double x [] = new double[n+1]; // node positions doublequadrature [] = {0.0, 0.0 ,0.0}; // itwillholdthequadratureresults doubletrueArea[] = { 0.58385316345285761300, // true areaforfunction 1 3.8856180831641267317, // true areaforfunction 2 1.3250027473578644309 // true areaforfunction 3 }; // node positions for (int i=0; i<=n; i++) x[i] = x0 + i*h; // Printweights and nodes System.out.println("------------------------------------------------------------------"); System.out.println("5-point Closed Newton Cotes quadrature\n"); System.out.println("Weights and nodes:"); for (int i=0; i<=n; i++) { System.out.printf("w[%d] = %f, x[%d] = %f\n", i, w[i], i, x[i]); } // Evaluatethequadratureoffirstfunctionusingthe 5-point rule quadrature[0] = 0.0; // initializetozeroformakingthe sum for (int i=0; i<=n; i++) quadrature[0] += (xn - x0)*w[i]*function1(x[i]); //addnodecontributionto sum // Evaluatethequadratureofsecondfunction quadrature[1] = 0.0; // initializetozeroformakingthe sum for (int i=0; i<=n; i++) quadrature[1] += (xn - x0)*w[i]*function2(x[i]); //addnodecontributionto sum // Evaluatethequadratureofthirdfunction quadrature[2] = 0.0; // initializetozeroformakingthe sum for (int i=0; i<=n; i++) quadrature[2] += (xn - x0)*w[i]*function3(x[i]); //addnodecontributionto sum System.out.println("Function\tAreaapproximation\tTruevalue\tError"); for (int i=0; i<3; i++) { double error = quadrature[i] - trueArea[i]; System.out.printf("%d\t\t%f\t\t%f\t%f\n", i+1, quadrature[i], trueArea[i], error); } System.out.println(); } /** * PURPOSE: Evaluatethequadratureofthe 3 functionsdefinedaboveusing * the Gaussian quadrature * INPUT: None * OUTPUT: printsthequadratureresultsonthescreen. */ publicstaticvoidgaussian() { int n = 5; // use 5 points double x0 = -1; // lowerlimit doublexn = 1; // upperlimit double w [] = { // weights (322 - 13*Math.sqrt(70))/900., (322 + 13*Math.sqrt(70))/900., 128./255., (322 + 13*Math.sqrt(70))/900., (322 - 13*Math.sqrt(70))/900., }; double x [] = { // node positions -Math.sqrt(5 + 2*Math.sqrt(10./7.))/3., -Math.sqrt(5 - 2*Math.sqrt(10./7.))/3., 0, Math.sqrt(5 - 2*Math.sqrt(10./7.))/3., Math.sqrt(5 + 2*Math.sqrt(10./7.))/3., }; doublequadrature [] = {0.0, 0.0 ,0.0}; // itwillholdthequadratureresults doubletrueArea[] = { 0.58385316345285761300, // true areaforfunction 1 3.8856180831641267317, // true areaforfunction 2 1.3250027473578644309 // true areaforfunction 3 }; // Printweights and nodes System.out.println("------------------------------------------------------------------"); System.out.println("5-point Gaussian quadrature\n"); System.out.println("Weights and nodes:"); for (int i=0; i ```
``` Related Topics   Java servlets and web frameworks   JavaScript Assignment Help   Java Assignment Help   Java Fundamentals Homework Help   Do my Java exam   Object-Oriented Programming Assignment Help   Computer Science Assignment Help ```
``` Related Blogs Java Tutors in USA Java tutors in the USAJava is a computing language designed for the development of desktop and mobile applications, embedded systems, and the processing of big data. Introduced in 1995, Java is so much like C and C + + but easier to use because it enforces the object-oriented programming model. One ... Read More Are You Troubled with Your Java Programming Homework? Are You Troubled with Your Java Programming Homework?Java programming language was derived from C but is more flexible and compatible with multiple platforms. Java’s true power lies within people’s ability to manipulate the objects and variables within a program, which is why it is considered an obj... Read More Why You May Seriously Need Help With Java Programming Homework? Why You May Seriously Need Help With Java Programming Homework?How well are you conversant with Java programming? Given Java homework, can you handle it correctly for impressive results? Well, if you can not, there is a need to seek help with the Java programming homework. Also, even after get... Read More Improving Your Java Coding Skills by Learning How to Debug Improving Your Java Coding Skills by Learning How to DebugIt is no secret that most students spend a lot of time debugging rather than writing their Java code. In most universities and colleges, professors will only teach you the concepts of coding in Java and not how to fix the defects in your soft... Read More Related Experts Java Assignment Helper Average rating on 213 reviews 4.7/5 Humphrey, J Las Vegas, USA PhD. in Programming, University of Nevada, USA 99.7% Success rate 1591 Completed orders 97 minutes Response time 11108 USD Earned Professional Java Assignment helper Average rating on 208 reviews 4.8/5 Lincoln, B London, UK Master’s Degree in Programming, University of Greenwich, UK 99.2% Success rate 2158 Completed orders 98 minutes Response time 12682 USD Earned Expert Java Assignment Helper Average rating on 172 reviews 4.7/5 Cecily, K Adelaide, Australia Master’s Degree in Programming, University of Melbourne, Australia 99.1% Success rate 1134 Completed orders 97 minutes Response time 11249 USD Earned ```
``` ```
``` ```
``` Get Free Quote Your Name Your E-mail Deadline Attachments 0 Files Selected Notes Quadrature Methods in Java submit your homework Your Name Your E-mail Deadline Attachments 0 Files Selected Notes ```
```   Contact Details Address:  5209 Cedar Glenn CT, Cumming, GA 30040 Call Us:  +1 (315) 557-6473 Email:  support@programminghomeworkhelp.com   Quick Links Submit Your Assignment Neil Harding - Lead Programming Tutor About Us Blog Frequently Asked Questions (FAQ) How We Work Privacy Policy Terms of Use Contact Us Refund Policy Business Practices Fair Use Policy Payment Experts Expert Registration Samples Take My Programming Exam Site Map   Countries United States United Kingdom Australia Canada © 2024 All Rights Reserved . Programming Assignment Help by expert coders var supportsPassive=!1;try{var s=Object.defineProperty({},"passive",{get:function(){supportsPassive=!0}});window.addEventListener("testPassive",null,s),window.removeEventListener("testPassive",null,s)}catch(e){}supportsPassive?document.addEventListener("touchstart",function(){},{passive:!0}):document.addEventListener("touchstart",!1),\$(".custom-url").click(function(t){t.preventDefault(),window.location.href=\$(this).data("url")}),\$(".social-network-link").click(function(t){t.preventDefault(),window.location.href=\$(this).data("url")}); jQuery.event.special.touchstart={setup:function(e,t,s){this.addEventListener("touchstart",s,{passive:!t.includes("noPreventDefault")})}},jQuery.event.special.touchmove={setup:function(e,t,s){this.addEventListener("touchmove",s,{passive:!t.includes("noPreventDefault")})}},jQuery.event.special.wheel={setup:function(e,t,s){this.addEventListener("wheel",s,{passive:!0})}},jQuery.event.special.mousewheel={setup:function(e,t,s){this.addEventListener("mousewheel",s,{passive:!0})}}; Attached Files File Actions ```