Question

In: Advanced Math

Write a program to solve the boundary value problem ? ′′ = ? ′ + 2?...

Write a program to solve the boundary value problem ? ′′ = ? ′ + 2? + cos ? for ? ? [0, ?/2] with ?( 0) = 0.3, ?( ?/ 2) = 0.1. Check your numerical solution with actual using necessary plot.(MATLAB)

Solutions

Expert Solution

We have solved the given ODE for exact solution and then solved numerically using finite difference method. All calculations are done in MATLAB. (code attached).

Now we will solve this system of linear equations to find yi

MATLAB code:

function [x,y]=finite_difference_ODE(n)

% n=number of subintervals;
% therefore number of nodes is n+1;
  
x0=0; xn=pi/2;
y0=0.3; yn=0.1;
h=(xn-x0)/n;
x=x0:h:xn;
A=zeros(n+1,n+1); % coefficient matrix of the system Ay=b;
b=zeros(n+1,1); % b vector of the system Ay=b;
  
A(1,1)=1; A(end,end)=1;
b(1)=y0; b(end)=yn;
  
for i=2:n
x1=x(i);
temp1=1/(h^2); % coefficient of y_(i-1);
temp2=-2/(h^2)+1/h-2; % coefficient of y_(i);
temp3=1/(h^2)-1/h; % coefficient of y_(i+1);
  
A(i,(i-1):(i+1))=[temp1 temp2 temp3];
b(i)=cos(x1);
end
  
y=A\b; % solving the system;
  
% Exact solution
A1=[1 1; exp(-pi/2) exp(pi)];
b1=[0.6;0.2];
c1=A1\b1;
x1=x0:0.01:xn;
yexact=c1(1)*exp(-x1)+c1(2)*exp(2*x1)-0.1*(sin(x1)+3*cos(x1));
  
plot(x,y,x1,yexact,'--','LineWidth',2);
xlabel('t','fontsize',18);
ylabel('y(t)','fontsize',18);
legend('Numerical solution','Actual solution','fontsize',14)
title('Numerical solution vs Actual solution for n=100','fontsize',18);
end
  


Related Solutions

Solve boundary value problem, use the method of undetermined coefficients when you solve for the particular...
Solve boundary value problem, use the method of undetermined coefficients when you solve for the particular solution y'' + 2y' + y = e-x(cosx-7sinx) y(0)=0 y(pi) = epi
Solve the following boundary value problem by Laplace Transform. (If you solve with another method you...
Solve the following boundary value problem by Laplace Transform. (If you solve with another method you will NOT get credit. There is nothing wrong about the conditions.) d2y dt2 + y = cos(2t); y0(0) = 0; y0( 2 ) = ?1:
Solve the given Boundary Value Problem. Apply the method undetermined coefficients when you solve for the...
Solve the given Boundary Value Problem. Apply the method undetermined coefficients when you solve for the particular solution. y′′+2y′+y=(e^-x)(cosx−sinx) y(0)=0,y(π)=e^π
A: Write a divide-and-conquer program to solve the following problem:
in Java A: Write a divide-and-conquer program to solve the following problem:     1. Let A[1..n] and B[1..n] be two arrays of distinct integers, each sorted in an increasing order.      2. Find the nth smallest of the 2n combined elements. Your program must run in O(log n) time. For example: n = 4If A[1..n] = {2, 5, 8, 9} and B[1..n] = {1, 4, 6, 7}The nth (i.e. 4th) smallest integer is 5.If A[1..n] = {2, 5, 8, 13}...
Write a complete and syntactically correct Python program to solve the following problem: Write a program...
Write a complete and syntactically correct Python program to solve the following problem: Write a program for your professor that allows him to keep a record of the students’ average grade in his class. The program must be written in accordance with the following specs: 1. The input must be interactive from the keyboard. You will take input for 12 students. 2. You will input the students’ name and an average grade. The student cannot enter an average below zero...
11. Solve numerically the following Boundary Value Problem. X2Y” – X(X+2)Y’ + (X+2)Y = 0 Y(1)...
11. Solve numerically the following Boundary Value Problem. X2Y” – X(X+2)Y’ + (X+2)Y = 0 Y(1) = e and Y(2) = 2e2 The value of e = 2.71828
Write and test MatLAB code implementing the mathematical models of the boundary value problem to evaluate...
Write and test MatLAB code implementing the mathematical models of the boundary value problem to evaluate the elastic deflection of the beam based on Euler-Bernoulli and Timoshenko theories with finite difference discretisation (for numerical integration and differentiation). The results must be plotted on a graph with labelled local maxima and minima
Boundary-Value Problems in Other Coordinate Systems Solve ∆u = 0 in a disk x^2 + y^2...
Boundary-Value Problems in Other Coordinate Systems Solve ∆u = 0 in a disk x^2 + y^2 ≤ 25, where u(5, θ) = 7 sin 3θ − 6 sin 8θ and u is bounded when   r = 0. Solve ∆u = 0 in an annulus 1 ≤ x^2+y^2 ≤ 4, where u(1, θ) = 75 sin θ, u(2, θ) = 60 cos θ. Find the steady-state temperature distribution in a disk of radius 1 if the upper half of the circumference...
(Use the string class to solve the problem) Write a program (in c++) that can be...
(Use the string class to solve the problem) Write a program (in c++) that can be used to train the user to use less sexist language by suggesting alternative versions of sentences given by the user. The program will ask for a sentence, read the sentence into a string variable, and replace all occurrences of masculine pronouns with gender-neutral pronouns. For example, it will replace “he” with “she or he”, and “him” with “her or him”. Be sure to preserve...
Use the method of Undetermined Coefficients to find the solution of the boundary value problem x^2...
Use the method of Undetermined Coefficients to find the solution of the boundary value problem x^2 y '' + y' + 2y = 6x +2 y(1) = 0 y(2) = 1
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT