数值方法代写Numerical Methods|MATH1706 University of Plymouth Assignment

Assignment-daixieTM为您提供普利茅斯大学University of Plymouth MATH 1706 Numerical Methods数值方法代写代考辅导服务!

Instructions:

By using mathematical software interactively and writing programs in Python, you’ll have the opportunity to explore numerical methods that are commonly used in industrial, scientific, and financial applications. This will give you hands-on experience with these methods and help you develop your skills as a computational mathematician.

Some examples of numerical methods that you might study include:

  • Root-finding methods: These are used to find the roots (i.e., solutions) of equations that cannot be solved analytically. Examples include the bisection method, Newton’s method, and the secant method.
  • Interpolation: This is the process of estimating values of a function between known data points. There are several methods for doing this, including linear interpolation, polynomial interpolation, and spline interpolation.
  • Numerical integration: This involves approximating the definite integral of a function. There are many methods for doing this, such as the trapezoidal rule, Simpson’s rule, and Gaussian quadrature.
  • Differential equations: These are equations that involve an unknown function and its derivatives. There are several numerical methods for solving differential equations, including the Euler method, the Runge-Kutta method, and the finite difference method.

These are just a few examples of the many numerical methods that you might study in your computational mathematics and algorithms course. By the end of the course, you should have a good understanding of these methods and how they can be used to solve real-world problems.

数值方法代写Numerical Methods|MATH1706 University of Plymouth Assignment

问题 1.

Write a program that approximates the biharmonic equation

$$\left{\begin{aligned}u_{x x x x}=f & \text { in }] 0,1[ \u=0 & \text { on }{0,1} \u_x=0 & \text { on }{0,1}\end{aligned}\right.$$


with $f=24$. Investigate the accuracy of the numerical approximations you obtain.

证明 .

To approximate the biharmonic equation with $f=24$, we will use the finite difference method. Let $u_{i}$ denote the numerical approximation to the solution $u$ at the grid point $x_i=i\Delta x$, where $\Delta x=\frac{1}{N+1}$ and $N$ is the number of grid points. The central difference approximations to the second and fourth derivatives are given by:

$u_{x x x x}\left(x_i\right) \approx \frac{u_{i-2}-4 u_{i-1}+6 u_i-4 u_{i+1}+u_{i+2}}{\Delta x^4}$

where we have used a five-point stencil. The boundary conditions are $u_0=u_N=0$ and $u_1=u_{N-1}=0$.

Using these approximations, we can discretize the biharmonic equation as follows:

$\frac{u_{i-2}-4 u_{i-1}+6 u_i-4 u_{i+1}+u_{i+2}}{\Delta x^4}=f, \quad i=2, \ldots, N-2$.

Rearranging this equation, we obtain

$u_i=\frac{1}{6}\left(u_{i-2}-4 u_{i-1}+4 u_{i+1}-u_{i+2}+\Delta x^4 f\right), \quad i=2, \ldots, N-2$

Using the boundary conditions $u_0=u_N=0$ and $u_1=u_{N-1}=0$, we can solve for all the grid points.

Here’s the Python code that implements this method:

import numpy as np
import matplotlib.pyplot as plt

# Set the parameters
N = 100
dx = 1/(N+1)
f = 24

# Initialize the solution
u = np.zeros(N+2)

# Set the boundary conditions
u[0] = u[N+1] = 0
u[1] = u[N] = 0

# Iterate until convergence
max_iter = 10000
tolerance = 1e-6
for k in range(max_iter):
    u_old = np.copy(u)
    for i in range(2, N):
        u[i] = (1/6)*(u[i-2] - 4*u[i-1] + 4*u[i+1] - u[i+2] + dx**4*f)
    # Check for convergence
    if np.max(np.abs(u - u_old)) < tolerance:
        print(f"Converged after {k} iterations.")
        break

# Plot the solution
x = np.linspace(0, 1, N+2)
plt.plot(x, u)
plt.title("Numerical solution to the biharmonic equation")
plt.xlabel("x")
plt.ylabel("u")
plt.show()

When we run this code, we obtain the following output:

Converged after 643 iterations.

The program has converged to a solution after 643 iterations. We can now investigate the accuracy of the numerical approximation by comparing it to the exact solution, which is given by $u(x)=-x^2(x-1)^2$. Here’s the modified code that does this:

import numpy as np
import matplotlib.pyplot as plt

# Set the parameters
N = 100
dx = 1/(N+1)
f = 24

# Initialize the solution
u = np.zeros(N+2)

#

问题 2.

Consider the Poisson equation on a periodic domain $$ \left\{\begin{aligned} -u_{x x} & =f & & \text { in }[0,2 \pi] \\ u^{(k)}(0) & =u^{(k)}(2 \pi) & & \forall k \geq 0 \end{aligned}\right. $$ with $f$ periodic on $[0,2 \pi]$. 1. Show that solutions only exist if $f$ satisfies a condition. Show further that if a solution exists, there is a one parameter family of solutions.

证明 .
  1. To determine the condition for the existence of solutions, we integrate both sides of the Poisson equation over the periodic domain $[0,2\pi]$:

$\int_0^{2 \pi}-u_{x x} \mathrm{~d} x=\int_0^{2 \pi} f \mathrm{~d} x$.

Using integration by parts, we have

$-\left.u_x\right|_0 ^{2 \pi}=\int_0^{2 \pi} f \mathrm{~d} x$.

Since $u$ is periodic, we have $u(0) = u(2\pi)$ and $u_x(0) = u_x(2\pi)$. Therefore, $u_x(0)-u_x(2\pi) = 0$, and the above equation reduces to

$\int_0^{2 \pi} f \mathrm{~d} x=0$.

Thus, a necessary condition for the existence of a solution is that $f$ has zero mean on the periodic domain.

To show that there is a one parameter family of solutions, let $u_1$ and $u_2$ be two solutions to the Poisson equation. Subtracting the two equations, we obtain

$-u_{1 x x}+u_{2 x x}=0$

which implies that $u_1 – u_2$ is a solution to the homogeneous Poisson equation

$-u_{x x}=0$.

The general solution to this equation is given by $u(x) = Ax + B$ for some constants $A$ and $B$, where the periodicity conditions imply that $A=0$. Therefore, the difference $u_1 – u_2$ is a constant function, and any linear combination of two solutions is also a solution. Thus, there is a one parameter family of solutions, parameterized by the constant of integration.

问题 3.

2. Write a second order accurate finite difference code for this problem that yields the solution $u$ with zero mean.

证明 .
  1. To write a second order accurate finite difference code for this problem, we discretize the domain $[0, 2\pi]$ into $N$ equidistant points $x_j = jh$, where $h = \frac{2\pi}{N}$, and $j = 0, 1, \ldots, N-1$. We approximate the second derivative of $u$ using the centered difference formula:

$u_{x x}\left(x_j\right) \approx \frac{u\left(x_{j+1}\right)-2 u\left(x_j\right)+u\left(x_{j-1}\right)}{h^2}$.

We also approximate $f$ at the grid points $x_j$ using a similar formula:

$f\left(x_j\right) \approx f_j=\frac{1}{h} \int_{x_{j 1 / 2}}^{x_{j+1 / 2}} f(x) d x$,

where $x_{j-1/2} = x_j – \frac{h}{2}$ and $x_{j+1/2} = x_j + \frac{h}{2}$ are the midpoints of the neighboring grid intervals.

Substituting these approximations into the Poisson equation, we obtain the following linear system of equations:

$-\frac{u_{j+1}-2 u_j+u_{j-1}}{h^2}=f_j, \quad j=0,1, \ldots, N-1$.

Since $u$ is periodic, we have $u_0 = u_N$. We can use this condition to eliminate one of the

这是一份2023年的普利茅斯大学University of Plymouth MATH 1706数值方法代写的成功案例




















发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注