# Numerical-Methods-with-Applications

Version 1.1.1 (111 MB) by
Teach numerical methods for interpolation, differentiation, integration, and solving ODEs and PDEs with MATLAB.
Updated 23 May 2024

# Numerical Methods with Applications

or

Curriculum Module

Created with R2021b. Compatible with R2021b and later releases.

# Information

This curriculum module contains interactive MATLAB® live scripts that teach fundamental concepts and basic terminology related to designing and implementing numerical methods related to interpolation, numerical integration and differentiation, and numerical solutions to ordinary and partial differential equations.

## Background

You can use these live scripts as demonstrations in lectures, class activities, or interactive assignments outside class. This module addresses standard topics from a first course in numerical methods including interpolation, numerical integration and derivation, and several numerical solution methods for ODEs and PDEs.

The instructions inside the live scripts will guide you through the exercises and activities. Get started with each live script by running it one section at a time. To stop running the script or a section midway (for example, when an animation is in progress), use the Stop button in the RUN section of the Live Editor tab in the MATLAB Toolstrip.

Solutions are available upon instructor request. Contact the MathWorks teaching resources team if you would like to request solutions, provide feedback, or if you have a question.

## Prerequisites

This module assumes familiarity with basic programming concepts such as floating-point doubles and strings, structures including constants, vectors, matrices, arrays, control flows including if/else, for loops, and while loops, and how to use them in MATLAB. These ideas are all presented with interactive examples in Fundamentals of Programming. This module assumes familiarity with polynomials, derivatives, and integrals. To use the partial differential equation scripts, a student must be familiar with the concepts of partial derivatives and multivariable functions. These scripts do not assume knowledge of analytic solutions to ordinary or partial differential equations.

## Getting Started

### On Desktop:

Download or clone this repository. Open MATLAB, navigate to the folder containing these scripts and double-click on NumerialMethods.prj. It will add the appropriate files to your MATLAB path and open an app that asks you where you would like to start.

Ensure you have all the required products (listed below) installed. If you need to include a product, add it using the Add-On Explorer. To install an add-on, go to the Home tab and select Add-Ons > Get Add-Ons.

## Products

MATLAB® is used throughout. Tools from the Symbolic Math Toolbox™ are used frequently as well.

• drawpolygon from Image Processing and Computer Vision™ is used to create datasets in Hand.mlx and MeasureLakeArea.mlx
• Statistics and Machine Learning Toolbox™ and the Curve Fitting Toolbox™ are used in Interpolation.mlx
• geoplayer from Automated Driving Toolbox™ is used in TrackStorms.mlx to create elegant visualizations, but pedagogically similar plots are demonstrated with geoplot as well.

# Scripts

## Interpolation.mlx

In this script, students will...

- define interpolation and explain how it is different from regression and extrapolation
- demonstrate multiple solutions to an interpolation problem, even when interpolating by polynomials
- implement three different interpolation functions
Applications
- Drawing a smooth rendition of their hand
- Tracking the path of a cyclone

Scaffolded Template Scripts
linInterp.m
pcHInterp.m
pcSpline.m

## NumericalDerivatives.mlx

In this script, students will...

- determine numerical derivative approximations formulas
- use Taylor's theorem to calculate the order of the error for a numerical approximation to a derivative
- demonstrate how numerical derivatives can magnify approximation errors
Applications
- Numerical solutions to differential equations

## NumericalIntegration.mlx

In this script, students will...

- implement Euler's method, Gaussian 2-point approximations, and Simpson's rule for numerical integration
- explain why higher-order approximations may not be appropriate in applications
Applications
- Measure the area of a lake

Scaffolded Template Scripts
eulerMethod.m
gauss2pt.m
simpsonsRule.m

## NumericalODEs.mlx

In this script, students will...

- implement Euler's method for first-order initial value problems
- calculate the error of their numerical solution
- implement a trapezoidal method
- implement a four-step Runge-Kutta method
- compare results with the built-in MATLAB solver ode45
Applications
- Model a pendulum with increasingly realistic assumptions

Scaffolded Template Scripts
eulerMethodDE.m
rk4.m

## NumericalPDEs.mlx

In this script, students will...

- identify errors from discretizing the problem and from discretizing the method and choose appropriate parameters to minimize overall error
- explain the importance of stability when choosing a numerical method
- implement explicit, implicit, and Crank-Nicolson methods to solve a 1-D heat equation
Applications
- Solve a heat equation

Scaffolded Template Scripts
explicitPDE.m
implicitPDE.m
cnPDE.m

# Related Courseware Modules

Courseware Module
Sample Content
Available on:
Applied Linear Algebra

GitHub

Programming: Structuring Code
Learn how to organize your code into functions,
debug, comment, and share

GitHub

Or feel free to explore our other modular courseware content.

# Contribute

Looking for more? Find an issue? Have a suggestion? Please contact the MathWorks teaching resources team. If you want to contribute directly to this project, you can find information about how to do so in the CONTRIBUTING.md page on GitHub.

### Cite As

Emma Smith Zbarsky (2024). Numerical-Methods-with-Applications (https://github.com/MathWorks-Teaching-Resources/Numerical-Methods-with-Applications/releases/tag/v1.1.1), GitHub. Retrieved .

##### MATLAB Release Compatibility
Created with R2021b
Compatible with R2021b and later releases
##### Platform Compatibility
Windows macOS Linux
##### Categories
Find more on Mathematics and Optimization in Help Center and MATLAB Answers
##### Communities
More Files in the  Distance Learning Community

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

#### Utilities/OldVersions

Version Published Release Notes
1.1.1

See release notes for this release on GitHub: https://github.com/MathWorks-Teaching-Resources/Numerical-Methods-with-Applications/releases/tag/v1.1.1

1.1.0

See release notes for this release on GitHub: https://github.com/MathWorks-Teaching-Resources/Numerical-Methods-with-Applications/releases/tag/v1.1.0

1.0.10.0

See release notes for this release on GitHub: https://github.com/MathWorks-Teaching-Resources/Numerical-Methods-with-Applications/releases/tag/v1.0.10

1.0.9.0

See release notes for this release on GitHub: https://github.com/MathWorks-Teaching-Resources/Numerical-Methods-with-Applications/releases/tag/v1.0.9

1.0.8.0

See release notes for this release on GitHub: https://github.com/MathWorks-Teaching-Resources/Numerical-Methods-with-Applications/releases/tag/v1.0.8

1.0.7

See release notes for this release on GitHub: https://github.com/MathWorks-Teaching-Resources/Numerical-Methods-with-Applications/releases/tag/v1.0.7

1.0.6

See release notes for this release on GitHub: https://github.com/MathWorks-Teaching-Resources/Numerical-Methods-with-Applications/releases/tag/v1.0.6

1.0.5

See release notes for this release on GitHub: https://github.com/MathWorks-Teaching-Resources/Numerical-Methods-with-Applications/releases/tag/v1.0.5

1.0.4

See release notes for this release on GitHub: https://github.com/MathWorks-Teaching-Resources/Numerical-Methods-with-Applications/releases/tag/v1.0.4

1.0.3

See release notes for this release on GitHub: https://github.com/MathWorks-Teaching-Resources/Numerical-Methods-with-Applications/releases/tag/v1.0.3

1.0.2

See release notes for this release on GitHub: https://github.com/MathWorks-Teaching-Resources/Numerical-Methods-with-Applications/releases/tag/v1.0.2

1.0.1

See release notes for this release on GitHub: https://github.com/MathWorks-Teaching-Resources/Numerical-Methods-with-Applications/releases/tag/v1.0.1

1.0.0

To view or report issues in this GitHub add-on, visit the GitHub Repository.
To view or report issues in this GitHub add-on, visit the GitHub Repository.