Numerical approximation of the solution

In summary, the conversation discusses how to change the MATLAB code to solve for u''=sin(2pix) with the boundary conditions u(-1)=0 and u(1)=0 over the interval [-1, 1]. The code provided includes a function f4 that creates a parabola, and the question is how to modify the code to solve for the given differential equation.
  • #1
splelvis
10
0
u''(x)=f(x),
boundary conditions u(a)=0,u(b)=0.
(u(x+h)-2u(x)+u(x-h))/h^2=f(x);

maltab code:

clear all
a=0;
b=1;
n=10;
h=(b-a)/(n+1);
x_with_boundary=linspace(a,b,n+2)';
x=x_with_boundary(2:n+1);
A=h^(-2).*(diag(ones(1,n-1),-1)+diag(-2.*ones(1,n),0)+diag(ones(1,n-1),1));
rhs=f4(x);
sol=A\rhs;
sol_with_boundary_conds=[0;sol;0];
plot(x_with_boundary,sol_with_boundary_conds);


open a new document,f4,
function y=f4(x)
y=ones(length(x),1);

parabola comes out.



now the question is ,

u''(x)=sin(2pix);
u(-1)=0;
u(1)=0;
interval[-1;1]

,how to change the MATLAB code to become u''=sin(2pix)?
thanks in advance
 
Physics news on Phys.org
  • #2
anyone can help?
 

What is numerical approximation of the solution?

Numerical approximation of the solution is a method used to find an approximate or estimated solution to a mathematical problem or equation using a series of calculations. It is often used when an exact solution cannot be obtained or is too complex to compute.

What are the advantages of using numerical approximation?

One of the main advantages of using numerical approximation is that it allows for the solution of complex mathematical problems that would be difficult or impossible to solve by hand. It also provides a quick and efficient way to obtain an approximate solution without the need for extensive calculations.

What are some common methods used in numerical approximation?

Some common methods used in numerical approximation include the finite difference method, the finite element method, and the Monte Carlo method. These methods involve breaking down a problem into smaller, more manageable parts and using numerical techniques to solve them.

What are the limitations of numerical approximation?

While numerical approximation can provide a quick and efficient way to obtain an approximate solution, it is important to note that the accuracy of the solution is dependent on the chosen method and the precision of the calculations. Additionally, some problems may be too complex for numerical approximation to provide an accurate solution.

How can numerical approximation be applied to real-world problems?

Numerical approximation has a wide range of applications in various fields such as engineering, physics, and economics. It can be used to solve problems involving complex systems, optimize processes, and simulate real-world scenarios. For example, it can be used in weather forecasting, designing structures, and predicting stock market trends.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
132
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
937
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
948
  • MATLAB, Maple, Mathematica, LaTeX
Replies
13
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
218
Back
Top