Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 15

Laboratory Activity No.

Error Calculations

Numerical methods employs an approximation to yield an estimate of the exact


solution. Thus, discrepancy or errors arise during calculation. The accuracy of
numerical calculation is quantified by the error of calculations. Errors can be
quantified as true error or approximate error.

The following exercise demonstrates the concept of error as quantified based on


true and approximate errors. This VI will compute true error and approximate
error in the calculation of e x using Maclaurin series.

1. Open labVIEW.
2. Open a new VI by clicking on Blank VI in the LabVIEW Getting Started
window.
3. Save the VI as Error Calculation.vi.
4. Create the front panel as shown in Figure 1.
 Double click on the front panel and type the Maclaurin series for e x .

Figure 1

1|Page
 Right-click on the front panel to open the Controls palette, and put down
a Numeric Control from the Modern Numeric sub-palette. Refer to Figure
2.

Figure 2

 Rename the label into value of x.


 Repeat 4b and rename the label into “Number of terms to be used in the
Maclaurin series.
 Right click on the front panel to open the control palette, and put down an
Array from the Modern Numeric sub-palette, as shown in Figure 3.

2|Page
Figure 3

 Right click on the front panel to open the control palette, and put down a
Numeric Indicator from the Modern Numeric sub-palette, as shown in
Figure 4. Place the Numeric Indicator inside the array as shown in Figure
5.

3|Page
Figure 4

Figure 5

 Adjust the size of the array and its dimension as shown in Figure 6.

4|Page
Figure 6

5. Create the block diagram shown in Figure 7.


 Right-click on the block diagram to open the Functions
palette and place down the mathscript from the Programming →
Structures sub-palette, as shown in Figure 8.

Figure 7

5|Page
Figure 8

6|Page
 Type the commands inside the Mathscript Node and add inputs and
outputs as shown in Figure 9. Refer to Figure 7 to identify input and
output variables needed.

Figure 9

7|Page
 Right-click on the block diagram to open the Functions palette and create
a For Loop structure from the Programming → Structures sub-palette, as
shown in Figure 10. Place the for-loop structure in such a way that the
mathscript node is positioned inside.

Figure 10

 Add shift register by right clicking on the right side of the for-loop
structure and select Add Shift Register. Refer to Figure 11.

8|Page
Figure 11

 Do the necessary connections of the shift register starting


from the output side (right side). Refer to Figure 7.

 Right click on the block diagram to open the functions palette


and place down the Build Array Icon as shown in Figure 12.

 Do the remaining wiring connections necessary as indicated in Figure 7.

9|Page
Figure 12

6. Run the VI and verify its operation.

 Click on the numeric control x and set its value to 2.


 Run the application by clicking on the Run button.
 Verify that the approximate value of e 2 , the relative true error, and the
relative approximate error indicators return the correct result.
 Run the VI for different values of x, and verify its operation.

10 | P a g e
Problem:

Modify the VI so that a pre-specified error tolerance, ε s , is used instead of the


number of terms of the Maclaurin series to control the running of the program.
Write the resulting approximate value of e x at x=5 when ε s is equal to 10%, 5%,
and 1% on the space provide below.Present your VI to your professor for
verification of your program.

Name:_Josef Geminiano_ Instructor’s Initial: ____________


Student Number:_20151144193_ Date performed: _October 16, 2020_

11 | P a g e
SUMMARY OF LEARNING OUTCOMES:
In this Third experiment for Numerical Control we still utilize the LabView
Software but in addition to the Mathlab exntension.

LabVIEW is a programming development environment purpose-built for


automated test and measurement. Engineers and scientists use LabVIEW in a
wide array of applications and industries to integrate hardware and collect
data in their test and measurement systems.

LabVIEW NXG has an interface to MATLAB. The interface document (.mli)


allows the user to define calls to a MATLAB file (.m or .mlx) in their G dataflow
application. MATLAB files can be either functions or scripts. NI recommends
users format MATLAB programs as functions because functions perform
better than scripts and offer a clean programming model. When executing the
application, the interface for MATLAB invokes MATLAB, which calls the
MATLAB file. Input data passes from the diagram to MATLAB, and data
returns from MATLAB to the diagram.

The Formula Node in LabVIEW software is a convenient, text-based node you


can use to perform complicated mathematical operations on a block diagram
using the C++ syntax structure. It is most useful for equations that have many
variables or are otherwise complicated. The text-based code simplifies the
block diagram and increases its readability. Furthermore, you can copy and
paste existing code directly into the Formula Node rather than recreating it
graphically. The Formula Node is available in all development versions of
LabVIEW and does not require an additional toolkit or add-on.

12 | P a g e
DISCUSSION:
This experiment talks all about the Error calculations in math. Here are the types of
Errors that can be found in Numerical Engineering.
Roundoff Error
Roundoff errors occur because computers have a limited ability to represent numbers.
For example, π has infinite digits, but due to precision limitations, only 16 digits may be
stored in MATLAB. While this roundoff error may seem insignificant, if your process
involves multiple iterations that are dependent on one another, these small errors may
accumulate over time and result in a significant deviation from the expected value.
Furthermore, if a manipulation involves adding a large and small number, the effect of
the smaller number may be lost if rounding is utilized. Thus, it is advised to sum
numbers of similar magnitudes first so that smaller numbers are not “lost” in the
calculation.
Truncation Error
Truncation errors are introduced when exact mathematical formulas are represented by
approximations. An effective way to understand truncation error is through a Taylor
Series approximation. Let’s say that we want to approximate some function, f(x) at the
point xi+1, which is some distance, h, away from the basepoint xi, whose true value is
shown in black in Figure 1. The Taylor series approximation starts with a single zero
order term and as additional terms are added to the series, the approximation begins to
approach the true value. However, an infinite number of terms would be needed to
reach this true value.
The Tradeoff in Errors
The total error of an approximation is the summation of roundoff error and truncation
error. As seen from the previous sections, truncation error decreases as step size
decreases. However, when step size decreases, this usually results in the necessity for
more precise computations which consequently results in an increase in roundoff error.
Therefore, the errors are in direct conflict with one another: as we decrease one, the
other increases.

13 | P a g e
CONCLUSION
As future Electronics Engineers it is imperative for us to determine the most efficient
way of achieving the tasks we are going to part take in and one way of efficiency
testing is knowing the error factor of each component/instance.
as stated by Wikibooks "When using numerical methods or algorithms and computing
with finite precision, errors of approximation or rounding and truncation are introduced.
It is important to have a notion of their nature and their order. A newly developed
method is worthless without an error analysis. Neither does it make sense to use
methods which introduce errors with magnitudes larger than the effects to be measured
or simulated. On the other hand, using a method with very high accuracy might be
computationally too expensive to justify the gain in accuracy."
The Tradeoff in Errors
The total error of an approximation is the summation of roundoff error and truncation
error. As seen from the previous sections, truncation error decreases as step size
decreases. However, when step size decreases, this usually results in the necessity for
more precise computations which consequently results in an increase in roundoff error.
Therefore, the errors are in direct conflict with one another: as we decrease one, the
other increases.
However, the optimal step size to minimize error can be determined. Using an iterative
method of trying different step sizes and recording the error between the approximation
and the true value, the following graph shown in Figure 2 will result. The minimum of
the curve corresponds to the minimum error achievable and corresponds to the optimal
step size. Any error to the right of this point (larger step sizes) is primarily due to
truncation error and the increase in error to the left of this point corresponds to where
roundoff error begins to dominate. While this graph is specific to a certain function and
type of approximation, the general rule and shape will still hold for other cases.

14 | P a g e
REFERENCES:
https://knowledge.ni.com/KnowledgeArticleDetails?
id=kA03q000000x30HCAQ&l=en-PH
http://www.engineering.uco.edu/~aaitmoussa/Courses/ENGR3703/Chapter1/c
h1_1.pdf
Chapra, Steven C. Applied Numerical Methods with MATLAB for Engineers
and Scientists. McGraw-Hill, 2017.
Class Notes from ENGRD 3200: Engineering Computation taught by Professor
Peter Diamessis at Cornell University

15 | P a g e

You might also like