Below is the prompt we are solving and a depiction of the system. The problem is asking for us to estimate the deflection (y) of a cantilever beam as the location (x) of the load (w) moves further down the beam's body. Euler's method is used to estimate the solution in the numerical approach, and the equation to the right is used for the analytical (exact) solution.
Figure 1: Depicts the analytical solution with 0.25m increments along the beam.
To solve using the analytical solution we simply plug in values of x, as well as our known values for the beam and load, and the given equation returns the exact deflection at that point. See below for an example calculation.
Figure 2: Depicts the numeric solution which untilizes the rate of change to estimate beam deflection. Step size 0.25m.
To solve using the numerical solution we must use the slope of the graph is various increments to estimate the next "step" in y. The smaller the increment, the more accurate this estimation is. Using Euler's method below, we differentiate the original deflection equation and move our dx and y(x(i)) over to the right side. This gives us an equation to evaluate y(x(i+1)) based on the rate at which y is increasing with small changes in x.
Euler's method is a common strategy used in engineering and physics to create models that closely estimate systems when exact (analytical) solutions are not feasible.
Figure 3: Depicts the analytical and numerical solutions side-by-side using step size 0.25m.
The analytical and numerical models will alway show slight disparity, as the numerical model is an estimation using the slope with each increment in distance. The analytical output for any given 'y' value appeared to be consistently larger than that of the numerical output. Using a smaller step size would decrease the error and the percent difference between these two approaches as the slopes would get increasingly more precise, which is illustrated below.
The approach used in the matlab code in Appendix I is one of many ways this problem can be solved. I chose this way because nothing is hard-coded into the equations and the organization of vectors is simple and legible. Each "x" value has a corresponding y_a and y_n value, allowing for easy plotting and data visualization.
Investigating the disparity between the numerical and analytical approaches, we can see below that using a smaller increment in x leads to significantly more accurate predictions in y. The blue line below is the numerical approach, and the green line is the analytical ("correct") approach to be used for comparison.
Figure 4: Shows the much greater disparity between the numerical and analytical approaches when compared to Figure 5. The numerical approach significantly underestimates the analytical approach when using a step size of 1m.
Figure 5: Same functions as the preceeding two figures, however using a step size of 0.125m. Notice how the numerical approach (blue) appears to closely follow the analyical values, exemplifying how smaller step sizes can significantly improve outcomes in numerical modeling.
Observe this same phenomenon below in the true percentage relative error calculations, where using dx values of 1m and 0.125 m leads to significantly different percent error outcomes. True percentage relatice error is calculated by dividing the difference between the estimated (numerical approach) and "true" (analytical approach) values by the "true" value, then multiplying by 100. As you can see, using smaller step sizes dramatically attentuates the overall difference between the analytical and numerical approaches. Interestingly, the error at the beginning is similar between the two groups of data, which makes sense looking at our estimations using Euler's method. Because the first few steps are using previously estimated values for y which have incorporated non-existant slopes, the numerical result will always underestimate the "true" value especially towards the lower end of the range. As x increases, it becomes a larger proportion of the overall length of the beam which decreases the impact underestimations of y(x(i-1)) have on the final value.
Figure 6: Depicts the percent error (difference between numerical and analytical appraches) for a step size of 1m. Notice the significantly larger area under the curve compared to Figure 7, which uses a step size of 0.125m.
Figure 7: Illustrates true percentage relative error when using a step size of 0.125m. When viewed in the context of Figure 6, it is clear how using smaller step sizes allows Euler's method to become more effective.