You are on page 1of 4

Analysis of a Tensile Test

Using the Least Squares Method in C++


Devyn Kirban
March 18, 2018
Abstract
When testing a material’s mechanical response, one of the most important tests is the tensile test.
In this paper, we will examine the stress vs. strain data produced from such a test. We will create
a best fit straight line by using the least squares method implemented in C++. Additionally, we
will force the trendline to pass through the origin and observe the ability to be a fit for the given
data.
Introduction
In this paper, we consider a rod specimen with one end clamped in a loading frame and the other
end subjected to a controlled displacement. A transducer connected in series with the specimen
can provide an electronic reading of the load corresponding to the displacement. The data
collected from a tensile test performed at room temperature on a copper rod is shown in Table 1
and Figure 1.
Table 1 Stress versus strain recorded during a tensile test [1].
Figure 1 Plot of stress and strain data from Table 1.
In this paper, we use the least squares method implemented in C++ to find the line of best fit to
the data in Table 1.
Numerical Analysis
The method we used to find the best fit line was the least squares method, also known as linear
regression. This method allowed us to fit a straight line to paired date points of (xi,yi).
The equation of a straight line is:

In this method, the sum of the squares of the errors calculated at each xi are minimized. The error
is:

e = yj – a0 – a1xj
for each point: (xi,yi)

where a0 and a1 are the values that minimizes Sr:


The coefficient of determination measures the accuracy of the fit and is described as:

where:

[2].
Results
When using the least squares method, it produced the equation of the stress-strain line that best
fits the data as:
y= 3.96587e-05x + 1.08184
The value of the coefficient of determination r2 = 0.429173.
This trendline does not pass through the origin. In Figure 2, the line that best fits the data is
shown.

Figure 2 Data and best fit line


We found that the equation satisfies zero stress at zero strain to be:
y= 0.21577x
The new value of the coefficient of determination = -1.55433e+07.
Figure 3 below showcases the new trendline that fails to match the trends of the data collected.

Figure 3 Data and best fit line passing through the origin
Both lines are poor fits to the given data.
Conclusion
This paper analyzed data from a tensile test that showcases a material’s mechanical response. By
creating a best fit straight line, the least squares method in C++ was extremely helpful to produce
a trendline equation. Additionally, we found out that forcing the trendline to include the origin
point of 0 strain and 0 fails to represent the trend of the data.
References
[1] Dr. Corina S. Drapaca, ESC 261M: Computational Methods for Engineers,
esc261m_lecture13_13.pdf and ESC261_PROJECT3_2018.docx. Canvas, web. March, 2018.
[2] ESC 261-Lecture Notes-Least Squares Method, 2018.
Appendix

You might also like