Home > Documents > Calculus and Differential Equationscecs.wright.edu/~sthomas/matlabnoteschap09.pdfCalculus and...

# Calculus and Differential Equationscecs.wright.edu/~sthomas/matlabnoteschap09.pdfCalculus and...

Date post: 21-Apr-2021
Category:
View: 42 times
of 23 /23
Chapter 9: Numerical Methods for Calculus and Differential Equations Numerical Integration Numerical Differentiation First-Order Differential Equations Higher-Order Differential Equations
Transcript

Chapter 9: Numerical Methods for Calculus and Differential Equations

• Numerical Integration • Numerical Differentiation • First-Order Differential Equations • Higher-Order Differential Equations

Integration Integration is a very important mathematical concept that used is by engineers for many situations. For instance, the pressure distribution on a dam can be used to determine the center of pressure on the dam. The integral of the pressure distribution is the area under the curve.

Numerical Integration Numerical integration is used when the function can’t be integrated directly. The area under the curve is estimated by dividing it using rectangular strips. A more accurate estimate is made by using trapezoidal strips.

Numerical Integration The area of a single trapezoid is given by:

Differentiation Differentiation of a function is the act of calculating the derivative of the function at any point. The derivative is the slope of the curve, which is the tangent line shown below as a red line. The reverse of differentiation is integration.

Numerical Differentiation Numerical differentiation is used for finding the slope of functions that are given by discrete data points, such as experimental data. Three methods are used: • Backward Difference • Forward Difference • Central Difference

Backward Difference Estimate the derivative or slope at a point (𝑑𝑦/𝑑𝑥) by looking at the data point to the left of the point of interest.

Forward Difference Estimate the derivative or slope at a point (𝑑𝑦/𝑑𝑥) by looking at the data point to the right of the point of interest.

Central Difference Estimate the derivative or slope at a point (𝑑𝑦/𝑑𝑥) by looking at the data points to the left and to the right of the point of interest.

First-Order Differential Equations • Initial-Value Problems • Euler Method • Predictor-Corrector Method • Time-Step Independence

Initial-Value Problems Consider a skydiver falling from an airplane. A Free-Body Diagram of the skydiver is as follows: Newton’s First Law is given by:

𝐹 = 𝑚𝑎

𝑚𝑔 − 𝐹𝐷 = 𝑚𝑑𝑣

𝑑𝑡

Substitute an expression for the Aerodynamic Drag Force:

𝑚𝑔 −1

2𝜌𝑣2𝐴𝐶𝐷 = 𝑚

𝑑𝑣

𝑑𝑡

Weight

Aero Drag

Acc

eler

atio

n

Initial-Value Problems

This is a First-Order Ordinary Differential Equation. In particular, it is called an Initial-Value Problem, because it is solved by knowing an Initial Value of the Dependent Variable. For instance, we can assume that the Downward Velocity of the skydiver was initially zero:

𝑣 = 0 at 𝑡 = 0

Weight

Aero Drag

Acc

eler

atio

n

𝑚𝑔 −1

2𝜌𝑣2𝐴𝐶𝐷 = 𝑚

𝑑𝑣

𝑑𝑡

Euler Method

This Initial-Value Problem can be solved for the skydiver’s velocity as a function of time by using the Euler Method, which starts with the definition of the Derivative:

𝑑𝑣

𝑑𝑡= lim

∆𝑡→0

𝑣 𝑡 + ∆𝑡 − 𝑣(𝑡)

∆𝑡

The derivative can be approximated by allowing ∆𝑡 be a small (but finite) value:

𝑑𝑣

𝑑𝑡≈

𝑣 𝑡 + ∆𝑡 − 𝑣(𝑡)

∆𝑡

𝑚𝑔 −1

2𝜌𝑣2𝐴𝐶𝐷 = 𝑚

𝑑𝑣

𝑑𝑡; 𝑣 = 0 at 𝑡 = 0

Euler Method 𝑑𝑣

𝑑𝑡=

1

𝑚𝑚𝑔 −

1

2𝜌𝑣2𝐴𝐶𝐷

𝑣 𝑡 + ∆𝑡 − 𝑣(𝑡)

∆𝑡=

1

𝑚𝑚𝑔 −

1

2𝜌𝑣2𝐴𝐶𝐷

𝑣 𝑡 + ∆𝑡 = 𝑣 𝑡 +∆𝑡

𝑚𝑚𝑔 −

1

2𝜌 𝑣 𝑡 2𝐴𝐶𝐷

Knowing the Initial Condition, the skydiver’s velocity can now be found by Marching Forward in Time.

Euler Method

𝑣 𝑡 + ∆𝑡 = 𝑣 𝑡 +∆𝑡

𝑚𝑚𝑔 −

1

2𝜌 𝑣 𝑡 2𝐴𝐶𝐷

This equation can be cast into a form appropriate for solution using MATLAB. This is called the Difference Equation:

𝑣𝑘+1 = 𝑣𝑘 +∆𝑡

𝑚𝑚𝑔 −

1

2𝜌 𝑣𝑘

2𝐴𝐶𝐷

where 𝑡𝑘+1 = 𝑡𝑘 + ∆𝑡.

Predictor-Corrector Method The Euler Method assumes that the right-hand side of the equation is constant over the time interval ∆𝑡. The Predictor-Corrector Method provides a more accurate estimate of the right-hand side, which improves the accuracy of the solution. This Two-Step Method uses the Euler Method to Estimate the velocity at 𝑡𝑘+1, then Corrects the Estimate using the Trapezoidal Rule.

Predictor-Corrector Method Euler Prediction:

𝑥𝑘+1 = 𝑣𝑘 +∆𝑡

𝑚𝑚𝑔 −

1

2𝜌 𝑣𝑘

2𝐴𝐶𝐷

Trapezoidal Correction:

𝑣𝑘+1 = 𝑣𝑘

+∆𝑡

2 1

𝑚𝑚𝑔 −

1

2𝜌 𝑣𝑘

2𝐴𝐶𝐷

+1

𝑚𝑚𝑔 −

1

2𝜌 𝑥𝑘+1

2𝐴𝐶𝐷

Falling Skydiver: Euler Method CD = 0.8; % Coefficient of Drag of the Skydiver's Body (Dimensionless) area = 0.4; % Projected Area of the Skydiver's Body, m^2 rho = 1.225; % Density of Air, kg/m^3 mass = 82; % Mass of Skydiver, kg gravity = 9.81; % Acceleration due to Gravity, m/s^2 N = 300; delta_t = 0.1; v = zeros(1,N); t = zeros(1,N); x(1) = 0; % Initial Position, m v(1) = 0.0; % Initial Velocity for k = 1:N v(k+1) = v(k) + (delta_t/mass)*(mass*gravity - 0.5*rho*v(k)^2*area*CD); x(k+1) = x(k) + delta_t/2*(v(k) + v(k+1)); t(k+1) = t(k) + delta_t; end

Time-Step Independence

The solution of the differential equation for the skydiver is dependent on the chosen time step ∆𝑡. As the time step size decreases, the solution curves begin to overlap. This is called Time-Step Independence. Conversely, if ∆𝑡 becomes too large, the solution can become unstable, as shown for ∆𝑡 = 5.0 seconds.

Higher-Order Differential Equations The methods used to solve first-order differential equations can be used to solve higher-order ordinary differential equations. Consider a Spring-Mass-Damper system:

Spring-Mass-Damper System

The mass is m, the spring constant is k, and the damping coefficient is c. Newton’s Second Law for this system is:

𝑚𝑥 + 𝑐𝑥 + 𝑘𝑥 = 0 where the first derivative of position with respect to time is

𝑥 =𝑑𝑥

𝑑𝑡 and the second derivative is 𝑥 =

𝑑2𝑥

𝑑𝑡2

Solve this equation by turning it into a system of two first-order differential equations. First, solve the equation for the second derivative:

𝑥 = −𝑐

𝑚𝑥 −

𝑘

𝑚𝑥

Spring-Mass-Damper System Let 𝑦1 = 𝑥 and 𝑦2 = 𝑥 . Taking the derivative of the first equation gives:

𝑦 1 = 𝑥 = 𝑦2 or 𝑦 1 = 𝑦2 Taking the derivative of the second equation gives:

𝑦 2 = 𝑥 = −𝑐

𝑚𝑥 −

𝑘

𝑚𝑥 or 𝑦 2 = −

𝑐

𝑚𝑦2 −

𝑘

𝑚𝑦1

Now use Euler’s Method by discretizing the system of equations as follows:

𝑦1,𝑘+1 = 𝑦1,𝑘 + ∆𝑡 ∙ 𝑦2,𝑘

𝑦2,𝑘+1 = 𝑦2,𝑘 + ∆𝑡 ∙ −𝑐

𝑚𝑦2 −

𝑘

𝑚𝑦1

Recommended