Given the one-dimensional Poisson equation d2f (1) sin (Tx) dx2 using boundary c
ID: 2964671 • Letter: G
Question
Given the one-dimensional Poisson equation
d2f (1) sin (Tx) dx2 using boundary conditions (a) Discretize the space derivative in the differential equation using a second-order central finite- difference approximation, and write the difference equation for fi (b) Solve x) numerically for -1 Sx S 1 using Ar and plot your computed fx) vs. x (c) Solve x) numerically for -1 S xSI using Ax and plot your computed fx) vs. x (d) solve x) numerically for -1 Kx 1 using Ar and plot your computed f(x) vs. x (e) Solve x) numerically for -1 x s 1 using Ar and plot your computed f(x) vs. x.Explanation / Answer
k = 1 / 32
x_arr = -1:k:1
matrix = zeros(length(x_arr) - 1, length(x_arr) - 1);
matrix(1, 1) = -1;
matrix(1, 2) = 1;
for i = 2:length(x_arr) - 2
matrix(i - 1, i) = 1;
matrix(i, i) = -2;
matrix(i + 1, i) = 1;
end
matrix(length(x_arr) - 1, length(x_arr) - 2) = 1;
matrix(length(x_arr) - 1, length(x_arr) - 2) = -2;
matrix1 = zeros(length(x_arr) - 1, 1);
matrix1(1, 1) = 2 * k;
for i = 2:length(x_arr) - 2
matrix1(i, 1) = -2*k*sin(pi * x_arr(i))
end
matrix;
matrix1;
ans = matrix1matrix
ans_temp = zeros(1, length(x_arr));
for i = 1:length(x_arr) - 1
ans_temp(1, i) = ans(1, i)
end
plot(x_arr, ans_temp)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.