06-12-2013 12:06 PM
How do you use the command quadn_trap within a Mathscript Node to calculate the integral 5x^4 dx numerically. The upper bound is 1 and the lower bound is 0. The answer should be 1.
Solved! Go to Solution.
06-13-2013 05:43 PM
Hello bumptee5,
To have the function evaluate 5x^4 the input vector should be x=[0,0,0,0,5]. The coefficients will follow [c,x,x^2…]. The way the quadn_trap function works the approximation will not be 1 but 2.5. If you want to evaluate the integral over the range use the quada_nc8 function.
f='5*x^4';
A=quada_nc8(f,0,1);
06-13-2013 08:02 PM
Hey Wear,
Cool. Never even heard of quada_nc8 function. Works like a charm, just don't forget the semicolons or single quotation marks.
Thought you might be interested in where my question originated. I am studying the 'Hands-On Introduction to LabVIEW' by John Essick. Problem 5 in Chapter 3 reads:
It is easy to show analytically that the integral (he has the elongated S symbol for the bounds with upper=1 and lower=0) 5x^4dx equals exactly 1. Open a Mathscript Interactive Window and then type help quadn_trap in the Command Window, After learning the syntax of the Mathscript command help quadn_trap write a VI called Numerical Integral that uses quadn_trap within a Mathscript Node to calculate the integral (again elongated S symbol with same bounds) 5x^4dx numerically and then displays the result in a front-panel indicator with Digits of Precision equal to 5. For your numerical result to be correct to five decimal places (i.e., the first five decimal places are all zero), how many x- values must be supplied to quadn_trap within the integration range x=0 to x=1?
Thanks for your help!
btfever