## Approximate Methods: The Rayleigh Ritz Method: Euler Bernoulli Beams under Lateral Loading

#### Learning Outcomes

the steps required to find an approximate solution for a beam system (and the extension to a continuum) using the Rayleigh Ritz method. (Step1: Assume a displacement function, apply the BC. Step 2: Write the expression for the PE of the system. Step 3: Find the minimizers of the PE of the system.)__Describe__the RR method to__Employ__an approximate solution for the displacement in an Euler Bernoulli beam(and the extension to a continuum).__compute__between the requirement for an approximate solution and an exact solution.__Differentiate__

### Euler Bernoulli Beams under Lateral Loading

For plane Euler Bernoulli beams under lateral loading, the unknown displacement function is . In this case, the potential energy of the system has the following form (See Euler Bernoulli Beam and energy expressions):

where is Young’s modulus, is the moment of inertia, and is the work done by all the external forces acting on the bar (concentrated forces and distributed loads). A few examples to solve for the displacements, rotations, shear forces, and moments for an Euler Bernoulli beam under lateral loading are presented in this section. Similar to the previous section, the Rayleigh Ritz method starts by choosing a form for the displacement function. This form has to satisfy the “essential” boundary conditions, which for this particular type of problems are those boundary conditions imposed on the displacements and the rotations. The following examples show the method for different external loads, and beam configurations.

#### Example 1: Cantilever Beam

Let a beam with a length and a constant cross sectional parameters area and moment of inertia be aligned with the coordinate axis . Assume that the beam is subjected to a constant force of value applied at the end in the direction shown in the figure. Assume that the bar is fixed (rotation and displacement are equal to zero) at the end . Find the displacement, rotation, bending moment, and shearing forces on the beam by directly solving the differential equation of equilibrium and then using the Rayleigh Ritz method assuming polynomials of the degrees (0,1, 2, 3, and 4). Assume the beam to be linear elastic with Young’s modulus and that the Euler Bernoulli Beam is an appropriate beam approximation.

##### Solution

**Exact Solution:**

First, the exact solution that would satisfy the equilibrium equations can be obtained. The equilibrium equation as shown in the Euler Bernoulli beam section when and are constant is:

For the shown cantilever beam, and therefore the exact solution for the displacement has the form:

where the constants can be obtained from the boundary conditions:

Therefore, the exact solution for the displacement , the rotation , the moment , and the shear are:

**The Rayleigh Ritz Method:**

The first step in the Rayleigh Ritz method finds the minimizer of the potential energy of the system which can be written as:

Notice that the potential energy lost by the action of the end force is equal to the product of – ( is acting downwards and is assumed upwards) and the displacement evaluated at . To find an approximate solution, an assumption for the shape or the form of has to be introduced.

**Polynomials of the Zero and First Degrees:**

If we assume that is a constant (polynomial of the zero degree) or a linear (polynomial of the first degree) function, and when attempting to satisfy the essential boundary conditions:

this leads to the trivial solution , which will automatically be rejected.

**Polynomial of the Second Degree:**

The approximate solution forms for the displacement , the rotation , the moment , and the shear force functions if is assumed to be a polynomial of the second degree are:

To satisfy the essential boundary conditions, we have:

Therefore, the solutions forms have only one parameter that can be controlled:

Substituting into the equation of the potential energy of an Euler Bernoulli beam:

The unknown coefficient can be obtained by minimizing the potential energy:

Therefore, the “best” parabolic approximation for along with the corresponding solutions for , and are given by:

Note that because of the simplicity of the approximation, the shear force (which is the third derivative) is always equal to zero.

**Polynomial of the Third Degree:**

The approximate solution forms for the displacement , the rotation , the moment , and the shear force functions if is assumed to be a polynomial of the third degree are:

To satisfy the essential boundary conditions, we have:

Therefore, the solutions forms have only two parameters and that can be controlled:

Substituting into the equation of the potential energy of an Euler Bernoulli beam:

The unknown coefficients and can be obtained by minimizing the potential energy:

Solving the above two equations yields:

Therefore, the “best” cubic approximation for along with the corresponding solutions for , and are given by:

The “approximate” solution obtained here is identical to the “exact” solution obtained above. This is because the trial function for was assumed to be a cubic polynomial and the exact solution is in fact a cubic polynomial. One should note that when the “form” or “shape” of the approximate solution contains the “form” or “shape” of the exact solution, then the Rayleigh Ritz method renders the exact solution! To see this, we are going to try a finer approximation (A polynomial of the fourth degree).

**Polynomial of the Fourth Degree:**

The approximate solution forms for the displacement , the rotation , the moment , and the shear force functions if is assumed to be a polynomial of the fourth degree are:

To satisfy the essential boundary conditions, we have:

Therefore, the solutions forms have the parameters , and that can be controlled:

Substituting into the equation of the potential energy of an Euler Bernoulli beam:

The unknown coefficients , and can be obtained by minimizing the potential energy:

Solving the above three equations yields:

Therefore, assuming a fourth order polynomial gives the same solution as a third order polynomial!

View Mathematica Code

Clear[a,x,V,M,P,y,L,EI]

M=EI*D[y[x],{x,2}];

V=EI*D[y[x],{x,3}];

th=D[y[x],x];

q=0;

M1=M/.x->0;

M2=M/.x->L;

V1=V/.x->0;

V2=V/.x->L;

y1=y[x]/.x->0;

y2=y[x]/.x->L;

th1=th/.x->0;

th2=th/.x->L;

s=DSolve[{EI*y””[x]==q,y1==0,th1==0,V2==P,M2==0},y,x];

y=y[x]/.s[[1]]

th=D[y,x]

M=EI*D[y,{x,2}]

V=EI*D[y,{x,3}]

(*Second Degree*)

Clear[y,x,M,V,th,EI,PE]

y=a2*x^2

th=D[y,x];

M=EI*D[y,{x,2}];

V=EI*D[y,{x,3}];

PE=EI/2*Integrate[D[y,{x,2}]^2,{x,0,L}]+P*(y/.x->L);

Eq2=D[PE,a2];

Sol=Solve[{Eq2==0},{a2}]

y=y/.Sol[[1]]

th/.Sol[[1]]

FullSimplify[M/.Sol[[1]]]

FullSimplify[V/.Sol[[1]]]

(*Third Degree*)

Clear[y,x,M,V,th,EI,PE]

y=a3*x^3+a2*x^2

th=D[y,x];

M=EI*D[y,{x,2}];

V=EI*D[y,{x,3}];

PE=EI/2*Integrate[D[y,{x,2}]^2,{x,0,L}]+P*(y/.x->L);

Eq1=D[PE,a3];

Eq2=D[PE,a2];

Sol=Solve[{Eq1==0,Eq2==0},{a3,a2}]

y=y/.Sol[[1]]

th/.Sol[[1]]

FullSimplify[M/.Sol[[1]]]

FullSimplify[V/.Sol[[1]]]

(*Fourth Degree*)

Clear[y,x,M,V,th,EI,PE]

y=a4*x^4+a3*x^3+a2*x^2

th=D[y,x];

M=EI*D[y,{x,2}];

V=EI*D[y,{x,3}];

PE=EI/2*Integrate[D[y,{x,2}]^2,{x,0,L}]+P*(y/.x->L);

Eq1=D[PE,a3];

Eq2=D[PE,a2];

Eq3=D[PE,a4];

Sol=Solve[{Eq1==0,Eq2==0,Eq3==0},{a3,a2,a4}]

y=y/.Sol[[1]]

th/.Sol[[1]]

FullSimplify[M/.Sol[[1]]]

FullSimplify[V/.Sol[[1]]]

#### Example 2: Simple Beam

Let a beam with a length and a constant moment of inertia be aligned with the coordinate axis . Assume that the beam is subjected to a distributed load .(Notice that the negative sign was added since is positive when it is in the direction of positive ). Assume that the beam is hinged at the ends and . Find the displacement, rotation, bending moment, and shearing forces on the beam by directly solving the differential equation of equilibrium and then using the Rayleigh Ritz method assuming polynomials of the degrees (0, 1, 2, 3 and 4). Assume the beam to be linear elastic with Young’s modulus and that the Euler Bernoulli Beam is an appropriate beam approximation. Compare the Rayleigh Ritz method with the exact solution.

##### Solution

**Exact Solution:**

First, the exact solution that would satisfy the equilibrium equations can be obtained. The equilibrium equation as shown in the Euler Bernoulli beam section when and are constant is:

For the shown simple beam, and therefore the exact solution for the displacement has the form:

where the constants can be obtained from the boundary conditions:

therefore,

Therefore, the exact solution for the displacement , the rotation , the moment , and the shear are:

**The Rayleigh Ritz Method:**

The first step in the Rayleigh Ritz method finds the minimizer of the potential energy of the system which can be written as:

To find an approximate solution, an assumption for the shape or the form of has to be introduced.

**Polynomials of the Zero and First Degrees:**

If we assume that is a constant (polynomial of the zero degree) or a linear (polynomial of the first degree) function, and when attempting to satisfy the essential boundary conditions:

this leads to the trivial solution , which will automatically be rejected.

**Polynomial of Higher Degrees:**

Similar to the previous examples, the coefficients are obtained by first satisfying the essential boundary conditions. Then, the remaining coefficients are obtained by minimizing the potential energy of the system. As shown in the plots below, the second and third degree trial functions give the same result, while the fourth and fifth degree trial functions give the same result. The solution is shown to give the accurate result when a polynomial of the fourth or higher degree is used.

View Mathematica Code

Clear[q,EI,y,x,c1,c2,c3,c4,L]

y=(q*x^4/24+c1*x^3/6+c2*x^2/2+c3*x+c4)/EI;

Eq1=y/.x-> 0;

Eq2=y/.x-> L;

Eq3=EI*D[y,{x,2}]/.x-> 0;

Eq4=EI*D[y,{x,2}]/.x-> L;

a=Solve[{Eq1==0,Eq2==0,Eq3==0,Eq4==0},{c1,c2,c3,c4}];

y=y/.a[[1]];

theta=D[y,x]/.a[[1]];

M=FullSimplify[EI*D[y,{x,2}]/.a[[1]]];

V=FullSimplify[EI*D[y,{x,3}]/.a[[1]]];

(*Second Degree*)

y2=a2*x^2+a1*x+a0;

s=Solve[{(y2/.x-> 0)==0,(y2/.x->L)==0},{a0,a1}];

y2=y2/.s[[1]];

theta2=D[y2,x];

M2=EI*D[y2,{x,2}];

V2=EI*D[y2,{x,3}];

PE=EI/2*Integrate[(D[y2,{x,2}])^2,{x,0,L}]-Integrate[q*y2,{x,0,L}];

Eq1=D[PE,a2];

a=Solve[{Eq1==0},{a2}];

y2=y2/.a[[1]];

theta2=D[y2,x]/.a[[1]];

M2=FullSimplify[EI*D[y2,{x,2}]/.a[[1]]];

V2=FullSimplify[EI*D[y2,{x,3}]/.a[[1]]];

(*Third Degree*)

y3=a3*x^3+a2*x^2+a1*x+a0;

s=Solve[{(y3/.x-> 0)==0,(y3/.x->L)==0},{a0,a1}];

y3=y3/.s[[1]];

theta3=D[y3,x];

M3=EI*D[y3,{x,2}];

V3=EI*D[y3,{x,3}];

PE=EI/2*Integrate[(D[y3,{x,2}])^2,{x,0,L}]-Integrate[q*y3,{x,0,L}];

Eq1=D[PE,a2];

Eq2=D[PE,a3];

a=Solve[{Eq1==0,Eq2==0},{a2,a3}];

y3=y3/.a[[1]];

theta3=D[y3,x]/.a[[1]];

M3=FullSimplify[EI*D[y3,{x,2}]/.a[[1]]];

V3=FullSimplify[EI*D[y3,{x,3}]/.a[[1]]];

(*fourth Degree*)

y4=a4*x^4+a3*x^3+a2*x^2+a1*x+a0;

s=Solve[{(y4/.x-> 0)==0,(y4/.x->L)==0},{a0,a1}];

y4=y4/.s[[1]];

theta4=D[y4,x];

M4=EI*D[y4,{x,2}];

V4=EI*D[y4,{x,3}];

PE=EI/2*Integrate[(D[y4,{x,2}])^2,{x,0,L}]-Integrate[q*y4,{x,0,L}];

Eq1=D[PE,a2];

Eq2=D[PE,a3];

Eq3=D[PE,a4];

a=Solve[{Eq1==0,Eq2==0,Eq3==0},{a2,a3,a4}];

y4=y4/.a[[1]];

theta4=D[y4,x]/.a[[1]];

M4=FullSimplify[EI*D[y4,{x,2}]/.a[[1]]];

V4=FullSimplify[EI*D[y4,{x,3}]/.a[[1]]];

(*fifth Degree*)

y5=a5*x^5+a4*x^4+a3*x^3+a2*x^2+a1*x+a0;

s=Solve[{(y5/.x-> 0)==0,(y5/.x->L)==0},{a0,a1}];

y5=y5/.s[[1]];

theta4=D[y5,x];

M5=EI*D[y5,{x,2}];

V5=EI*D[y5,{x,3}];

PE=EI/2*Integrate[(D[y5,{x,2}])^2,{x,0,L}]-Integrate[q*y5,{x,0,L}];

Eq1=D[PE,a2];

Eq2=D[PE,a3];

Eq3=D[PE,a4];

Eq4=D[PE,a5];

a=Solve[{Eq1==0,Eq2==0,Eq3==0,Eq4==0},{a2,a3,a4,a5}];

y5=y5/.a[[1]];

theta5=D[y5,x]/.a[[1]];

M5=FullSimplify[EI*D[y5,{x,2}]/.a[[1]]];

V5=FullSimplify[EI*D[y5,{x,3}]/.a[[1]]];

EI = 200000*1000000*4*100000000/1000000000000;

q = -25*1000;

L = 10;

Plot[{y,y2,y4},{x,0,L},AxesLabel-> {“x (m)”,”y (m)”},PlotLegends->{Style[“Exact y”,Bold,12],Style[“y2”,Bold,12],Style[“y4”,Bold,12]}] Plot[{theta,theta2,theta4},{x,0,L},AxesLabel-> {“x (m)”,”theta”},PlotLegends-> {Style[“Exact theta”,Bold,12],Style[“theta 2”,Bold,12],Style[“theta 4”,Bold,12]}]

Plot[{M,M2,M4},{x,0,L},AxesLabel-> {“x (m)”,”M (N.m.)”},PlotLegends-> {Style[“Exact M”,Bold,12],Style[“M2”,Bold,12],Style[“M4”,Bold,12]}] Plot[{V,V2,V4},{x,0,L},AxesLabel-> {“x (m)”,”V (N)”},PlotLegends->{Style[“Exact V”,Bold,12],Style[“V 2”,Bold,12],Style[“V4”,Bold,12]}]

#### Example 3: Cantilever Beam with a Varying Cross Sectional Area

Let a beam with a length and with a constant width and a linearly varying height ( and ) be aligned with the coordinate axis . Assume that the beam has a fixed left end and had a shearing load acting downwards of 10kN on its right end. Find the displacement, bending moment, and shearing force on the beam by directly solving the differential equation of equilibrium and then using the Rayleigh Ritz method assuming polynomials of the degrees (0, 1, 2, 3, 4, 5, 6, 7). Assume the beam to be linear elastic with Young’s modulus and that the Euler Bernoulli Beam is an appropriate beam approximation. Compare the Rayleigh Ritz method with the exact solution.

##### Solution

Exact Solution: First, the exact solution that would satisfy the equilibrium equations can be obtained. The equilibrium equation as shown in the Euler Bernoulli beam section apply only when and are constant. Since is variable, the differential equation has the form:

For the cantilever beam, . For consistency in the units, in all the following calculations and . The moment of inertia is a function of as follows:

The exact solution can be obtained using Mathematica. The following are the four boundary conditions required:

Using Mathematica, the above differential equation can be solved to yield the following exact solution for :

The associated moment in N.m. and shearing force in N. are given by:

Obviously, as the beam is statically determinate, the equations for the moment and shear are very simple. However, the variable cross section leads to a complicated form for the displacement . Note that traditionally, in structural engineering applications, a constant cross section with the intermediate height of two thirds of the maximum height can be assumed to simplify the equations.

**The Rayleigh Ritz Method:**

The first step in the Rayleigh Ritz method finds the minimizer of the potential energy of the system which can be written as:

Notice that the potential energy lost by the action of the end force is equal to the product of – ( is acting downwards and y is assumed upwards) and the displacement evaluated at . To find an approximate solution, an assumption for the shape or the form of has to be introduced.

**Polynomials of the Zero and First Degrees:**

If we assume that is a constant (polynomial of the zero degree) or a linear (polynomial of the first degree) function, and when attempting to satisfy the essential boundary conditions:

this leads to the trivial solution , which will automatically be rejected.

**Polynomial of the Second Degree:**

The approximate solution forms for the displacement , the rotation , the moment , and the shear force functions if is assumed to be a polynomial of the second degree are:

To satisfy the essential boundary conditions, we have:

Therefore, the solutions forms have only one parameter that can be controlled:

Substituting into the equation of the potential energy of an Euler Bernoulli beam:

Note that is a function of and so it stays inside the integral. The unknown coefficient can be obtained by minimizing the potential energy:

Therefore, the “best” parabolic approximation for along with the corresponding solutions for and are given by:

**Polynomial of the Third Degree:**

The approximate solution forms for the displacement , the rotation , the moment , and the shear force functions if is assumed to be a polynomial of the third degree are:

To satisfy the essential boundary conditions, we have:

Therefore, the solutions forms have only two parameters and that can be controlled:

Substituting into the equation of the potential energy of an Euler Bernoulli beam:

The unknown coefficients and can be obtained by minimizing the potential energy:

Solving the above two equations yields:

Therefore, the “best” cubic approximation for along with the corresponding solutions for , and are given by:

**Polynomials of the Fourth Degree:**

The approximate solution forms for the displacement , the rotation , the moment , and the shear force functions if is assumed to be a polynomial of the fourth degree are:

To satisfy the essential boundary conditions, we have:

Therefore, the solutions forms have the parameters , and that can be controlled:

Substituting into the equation of the potential energy of an Euler Bernoulli beam:

The unknown coefficients , and can be obtained by minimizing the potential energy:

Solving the above three equations yields:

Therefore, assuming a fourth order polynomial gives the following set of solutions:

Approximate solutions using higher order polynomials can be obtained similarly. The following plots show the convergence of the polynomial functions to the exact solution up to a polynomial of the sixth degree (Mathematica code is given below). In the first plot, it is clear that a polynomial of the second degree is capable of capturing the displacement quite accurately. However, the corresponding approximate solutions for the moment and shear are not as accurate. The accuracy of the approximate solution for the bending moment is higher than that for the shearing force and that is because the moment is related to the second derivative of while the shear is related to the third derivative of . It takes up to a polynomial of the seventh degree for for the approximate shearing force to have a flat distribution similar to the exact solution.

View Mathematica Code

b = 1/4;

L = 8;

t = (1/2 – 1/4*X1/L);

Ii = b*t^3/12;

Ee = 20*10^9;

P = 10000;

a = DSolve[{D[Ee*Ii*y”[X1], {X1, 2}] == 0, y[0] == 0, y'[0] == 0, y”[L] == 0, (D[Ee*Ii, X1] /. X1 -> L)*y”[L] + (Ee*Ii /. X1 -> L)*y”'[L] == P}, y[X1], X1, Assumptions -> 0 <= X1 <= L]

y = FullSimplify[Chop[N[y[X1] /. a[[1]]]]]

th = D[y, X1];

M = FullSimplify[Ee*Ii*D[y, {X1, 2}]]

V = FullSimplify[D[M, X1]]

Plot[y, {X1, 0, L}, PlotLabel -> “Displacement y”, AxesLabel -> {“X1 (m)”, “y (m)”}, PlotLegends -> {“y exact”}]

Plot[M, {X1, 0, L}, PlotLabel -> “Moment M”, AxesLabel -> {“X1 (m)”, “M (N.m)”}, PlotLegends -> {“M exact”}]

Plot[V, {X1, 0, L}, PlotRange -> {{0, L}, {0, 2 P}}, PlotLabel -> “Shear V”, AxesLabel -> {“X1 (m)”, “V (N)”}, PlotLegends -> {“V exact”}]

Print[“Second Order Polynomial”]

y2 = a2*X1^2;

d2y = D[y2, {X1, 2}];

PE = Integrate[Ee*Ii/2*d2y^2, {X1, 0, L}] – (-P)*y2 /. X1 -> L;

sol = Solve[D[PE, a2] == 0, a2]

y2 = y2 /. sol[[1]]

M2 = FullSimplify[Ee*Ii*D[y2, {X1, 2}]]

V2 = FullSimplify[D[M2, X1]]

Plot[{y, y2}, {X1, 0, L}, PlotLabel -> “Displacement y”, AxesLabel -> {“X1 (m)”, “y (m)”}, PlotLegends -> {“y exact”, “y2”}]

Plot[{M, M2}, {X1, 0, L}, PlotLabel -> “Moment M”, AxesLabel -> {“X1 (m)”, “M (N.m)”}, PlotLegends -> {“M exact”, “M2”}]

Plot[{V, V2}, {X1, 0, L}, PlotRange -> {{0, L}, {0, 2 P}}, PlotLabel -> “Shear V”, AxesLabel -> {“X1 (m)”, “V (N)”}, PlotLegends -> {“V exact”, “V2”}]

Print[“Third Order Polynomial”]

y3 = a2*X1^2 + a3*X1^3;

d2y = D[y3, {X1, 2}];

PE = Integrate[Ee*Ii/2*d2y^2, {X1, 0, L}] – (-P)*y3 /. X1 -> L;

sol = Solve[{D[PE, a2] == 0, D[PE, a3] == 0}, {a2, a3}]

y3 = y3 /. sol[[1]]

M3 = FullSimplify[Ee*Ii*D[y3, {X1, 2}]]

V3 = FullSimplify[D[M3, X1]]

Plot[{y, y3}, {X1, 0, L}, PlotLabel -> “Displacement y”, AxesLabel -> {“X1 (m)”, “y (m)”}, PlotLegends -> {“y exact”, “y3”}]

Plot[{M, M3}, {X1, 0, L}, PlotLabel -> “Moment M”, AxesLabel -> {“X1 (m)”, “M (N.m)”}, PlotLegends -> {“M exact”, “M3”}]

Plot[{V, V3}, {X1, 0, L}, PlotRange -> {{0, L}, {0, 2 P}}, PlotLabel -> “Shear V”, AxesLabel -> {“X1 (m)”, “V (N)”}, PlotLegends -> {“V exact”, “V3”}]

Print[“Fourth Order Polynomial”]

y4 = a2*X1^2 + a3*X1^3 + a4*X1^4;

d2y = D[y4, {X1, 2}];

PE = Integrate[Ee*Ii/2*d2y^2, {X1, 0, L}] – (-P)*y4 /. X1 -> L;

sol = Solve[{D[PE, a2] == 0, D[PE, a3] == 0, D[PE, a4] == 0}, {a2, a3, a4}]

y4 = y4 /. sol[[1]]

M4 = FullSimplify[Ee*Ii*D[y4, {X1, 2}]]

V4 = FullSimplify[D[M4, X1]]

Plot[{y, y4}, {X1, 0, L}, PlotLabel -> “Displacement y”, AxesLabel -> {“X1 (m)”, “y (m)”}, PlotLegends -> {“y exact”, “y4”}]

Plot[{M, M4}, {X1, 0, L}, PlotLabel -> “Moment M”, AxesLabel -> {“X1 (m)”, “M (N.m)”}, PlotLegends -> {“M exact”, “M4”}]

Plot[{V, V4}, {X1, 0, L}, PlotRange -> {{0, L}, {0, 2 P}}, PlotLabel -> “Shear V”, AxesLabel -> {“X1 (m)”, “V (N)”}, PlotLegends -> {“V exact”, “V4”}]

Print[“Fifth Order Polynomial”]

y5 = a2*X1^2 + a3*X1^3 + a4*X1^4 + a5*X1^5;

d2y = D[y5, {X1, 2}];

PE = Integrate[Ee*Ii/2*d2y^2, {X1, 0, L}] – (-P)*y5 /. X1 -> L; sol = Solve[{D[PE, a2] == 0, D[PE, a3] == 0, D[PE, a4] == 0, D[PE, a5] == 0}, {a2, a3, a4, a5}]

y5 = y5 /. sol[[1]]

M5 = FullSimplify[Ee*Ii*D[y5, {X1, 2}]]

V5 = FullSimplify[D[M5, X1]]

Plot[{y, y5}, {X1, 0, L}, PlotLabel -> “Displacement y”, AxesLabel -> {“X1 (m)”, “y (m)”}, PlotLegends -> {“y exact”, “y5”}]

Plot[{M, M5}, {X1, 0, L}, PlotLabel -> “Moment M”, AxesLabel -> {“X1 (m)”, “M (N.m)”}, PlotLegends -> {“M exact”, “M5”}]

Plot[{V, V5}, {X1, 0, L}, PlotRange -> {{0, L}, {0, 2 P}}, PlotLabel -> “Shear V”, AxesLabel -> {“X1 (m)”, “V (N)”}, PlotLegends -> {“V exact”, “V5”}]

Print[“Sixth Order Polynomial”]

y6 = a2*X1^2 + a3*X1^3 + a4*X1^4 + a5*X1^5 + a6*X1^6;

d2y = D[y6, {X1, 2}];

PE = Integrate[Ee*Ii/2*d2y^2, {X1, 0, L}] – (-P)*y6 /. X1 -> L; sol = Solve[{D[PE, a2] == 0, D[PE, a3] == 0, D[PE, a4] == 0, D[PE, a5] == 0, D[PE, a6] == 0}, {a2, a3, a4, a5, a6}]

y6 = y6 /. sol[[1]]

M6 = FullSimplify[Ee*Ii*D[y6, {X1, 2}]]

V6 = FullSimplify[D[M6, X1]]

Plot[{y, y6}, {X1, 0, L}, PlotLabel -> “Displacement y”, AxesLabel -> {“X1 (m)”, “y (m)”}, PlotLegends -> {“y exact”, “y6”}]

Plot[{M, M6}, {X1, 0, L}, PlotLabel -> “Moment M”, AxesLabel -> {“X1 (m)”, “M (N.m)”}, PlotLegends -> {“M exact”, “M6”}]

Plot[{V, V6}, {X1, 0, L}, PlotRange -> {{0, L}, {0, 2 P}}, PlotLabel -> “Shear V”, AxesLabel -> {“X1 (m)”, “V (N)”}, PlotLegends -> {“V exact”, “V6”}]

Print[“Seventh Order Polynomial”]

y7 = a2*X1^2 + a3*X1^3 + a4*X1^4 + a5*X1^5 + a6*X1^6 + a7*X1^7; d2y = D[y7, {X1, 2}];

PE = Integrate[Ee*Ii/2*d2y^2, {X1, 0, L}] – (-P)*y7 /. X1 -> L;

sol = Solve[{D[PE, a2] == 0, D[PE, a3] == 0, D[PE, a4] == 0, D[PE, a5] == 0, D[PE, a6] == 0, D[PE, a7] == 0}, {a2, a3, a4, a5,a6, a7}]

y7 = y7 /. sol[[1]]

M7 = FullSimplify[Ee*Ii*D[y7, {X1, 2}]]

V7 = FullSimplify[D[M7, X1]]

Plot[{y, y7}, {X1, 0, L}, PlotLabel -> “Displacement y”, AxesLabel -> {“X1 (m)”, “y (m)”}, PlotLegends -> {“y exact”, “y7”}]

Plot[{M, M7}, {X1, 0, L}, PlotLabel -> “Moment M”, AxesLabel -> {“X1 (m)”, “M (N.m)”}, PlotLegends -> {“M exact”, “M7”}]

Plot[{V, V7}, {X1, 0, L}, PlotRange -> {{0, L}, {0, 2 P}}, PlotLabel -> “Shear V”, AxesLabel -> {“X1 (m)”, “V (N)”}, PlotLegends -> {“V exact”, “V7”}]

Plot[{y, y2, y3, y4, y5, y6, y7}, {X1, 0, L}, PlotLabel -> “Displacement y”, AxesLabel -> {“X1 (m)”, “y (m)”}, PlotLegends -> {“y exact”, “y2”, “y3”, “y4”, “y5”, “y6”, “y7”}]

Plot[{M, M2, M3, M4, M5, M6, M7}, {X1, 0, L}, PlotLabel -> “Moment M”, AxesLabel -> {“X1 (m)”, “M (N.m)”}, PlotLegends -> {“M exact”, “M2”, “M3”, “M4”, “M5”, “M6”, “M7”}]

Plot[{V,V2,V3,V4,V5,V6,V7}, {X1, 0, L}, PlotRange ->{{0, L}, {0, 2 P}},PlotLabel->”Shear V”,AxesLabel -> {“X1 (m)”, “V (N)”},PlotLegends -> {“V exact”, “V2”, “V3”, “V4”, “V5”, “V6”, “V7”}]