<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="es">
		<id>https://mat.caminos.upm.es/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Marino+Rivera</id>
		<title>MateWiki - Contribuciones del usuario [es]</title>
		<link rel="self" type="application/atom+xml" href="https://mat.caminos.upm.es/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Marino+Rivera"/>
		<link rel="alternate" type="text/html" href="https://mat.caminos.upm.es/wiki/Especial:Contribuciones/Marino_Rivera"/>
		<updated>2026-05-04T14:09:37Z</updated>
		<subtitle>Contribuciones del usuario</subtitle>
		<generator>MediaWiki 1.26.2</generator>

	<entry>
		<id>https://mat.caminos.upm.es/w/index.php?title=Heat_equation_(Grupo_1B)&amp;diff=13571</id>
		<title>Heat equation (Grupo 1B)</title>
		<link rel="alternate" type="text/html" href="https://mat.caminos.upm.es/w/index.php?title=Heat_equation_(Grupo_1B)&amp;diff=13571"/>
				<updated>2014-05-20T15:42:10Z</updated>
		
		<summary type="html">&lt;p&gt;Marino Rivera: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ TrabajoED |Heat equation. Grupo 1-B | [[:Categoría:Ecuaciones Diferenciales|Ecuaciones Diferenciales]]|[[:Categoría:ED13/14|Curso 2013-14]] | Sandro Andrés Martínez &lt;br /&gt;
 &lt;br /&gt;
David Ayala Díez &lt;br /&gt;
 &lt;br /&gt;
Claudia Cózar Coarasa  &lt;br /&gt;
&lt;br /&gt;
Lorena de la Fuente Sanz  &lt;br /&gt;
&lt;br /&gt;
Marino Rivera Muñoz &lt;br /&gt;
  &lt;br /&gt;
José Manuel Torres Serrano }}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this work we have studied the modeling of the heat equation, according to Fourier's law discovered in the nineteenth century.&lt;br /&gt;
&lt;br /&gt;
= Well proposed problem  =&lt;br /&gt;
&lt;br /&gt;
[[Archivo:Nueva imagen.png|thumb|300px|left| Thin rod of length L]]&lt;br /&gt;
&lt;br /&gt;
We will raise the system of equations that satisfies &amp;lt;math&amp;gt;u(x,t)&amp;lt;/math&amp;gt; assuming that the temperature of the rod &amp;lt;math&amp;gt;u(x,t)&amp;lt;/math&amp;gt; satisfies the heat equation &amp;lt;math&amp;gt;u_t-u_{xx}=0&amp;lt;/math&amp;gt;. First, we have a thin, homogeneous and thermally isolated by its lateral surface rod of length  &amp;lt;math&amp;gt;L=3&amp;lt;/math&amp;gt;. At its left end the rod is in contact with a material whose temperature is maintained at 0°C, while the right is in contact with the material at 10°C. We also know that at the initial moment, the temperature distribution follows the &amp;lt;math&amp;gt;u(x,0)=u_0(x)&amp;lt;/math&amp;gt; function specified below. Assuming a standard &amp;lt;math&amp;gt;c=\rho=k=1&amp;lt;/math&amp;gt; parameters and there are no heat sources or sinks along the rod, the problem we have to solve is:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;math&amp;gt;&lt;br /&gt;
(P)&lt;br /&gt;
\begin{cases}&lt;br /&gt;
u_t-u_{xx}=0, \qquad x\epsilon(0,3), t&amp;gt;0\\&lt;br /&gt;
u(0,t)=0, u(3,t)=10, \qquad t&amp;gt;0\\&lt;br /&gt;
u(x,0)=u_0(x), \qquad x\epsilon[0,3]&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
:&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
u_0(x)=&lt;br /&gt;
\begin{cases}&lt;br /&gt;
10x/3 &amp;amp;  \mbox{si}  &amp;amp;  x \in \mbox{(0,1)}\cup\mbox{(2,3)}   \\&lt;br /&gt;
100     &amp;amp;  \mbox{si}  &amp;amp;   x \in \mbox{(1,2)}   &lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Then we will define what is a well proposed problem is one that meets the following:&lt;br /&gt;
&lt;br /&gt;
•	Existence: problem &amp;lt;math&amp;gt;(P)&amp;lt;/math&amp;gt; admits a solution &amp;lt;math&amp;gt;u(x,t)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
•	Uniqueness: if there is a solution &amp;lt;math&amp;gt;(P)&amp;lt;/math&amp;gt; it has to be unique.&lt;br /&gt;
&lt;br /&gt;
•	Stability with respect to initial data: &lt;br /&gt;
We consider the problem:&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
(P_1)&lt;br /&gt;
\begin{cases}&lt;br /&gt;
u_t-u_{xx}=0, \qquad x\epsilon(0,3), t&amp;gt;0\\&lt;br /&gt;
u(0,t)=0, u(3,t)=10, \qquad t&amp;gt;0\\&lt;br /&gt;
u(x,0)=h(x), \qquad x\epsilon[0,3]&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Be &amp;lt;math&amp;gt;u(x,t)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;u_1(x,t)&amp;lt;/math&amp;gt; &amp;lt;math&amp;gt;(P)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;(P_1)&amp;lt;/math&amp;gt; solutions respectively. We say that the &amp;lt;math&amp;gt;(P)&amp;lt;/math&amp;gt; problem is stable with respect to initial data if we prove the inequality of type &amp;lt;math&amp;gt;sup_{(x,t)\in [0,3]x[0,\infty]}\left|u(x,t)-u_1(x,t)\right|\leq Csup_{(x,t)\in [0,3]x[0,\infty]}\left|u_0(x)-h(x)\right|&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; absolute, constant independent of the &amp;lt;math&amp;gt;(P)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;(P_1)&amp;lt;/math&amp;gt; problems.&lt;br /&gt;
&lt;br /&gt;
That &amp;lt;math&amp;gt; (P) &amp;lt;/math&amp;gt; is stable with respect to initial data tells us that if &amp;lt;math&amp;gt; h (x) &amp;lt;/math&amp;gt; is close to &amp;lt;math&amp;gt; u_0 (x) &amp;lt;/math&amp;gt; in the sense that &amp;lt;math&amp;gt; sup_ {(x, t) \ in [0,3] x [0, \infty]} \left | u_0 (x)-h (x) \right | &amp;lt;/math&amp;gt; is small, then the &amp;lt;math&amp;gt;  u (x, t) &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; u_1 (x, t) &amp;lt;/math&amp;gt; solutions are also nearby.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Resolution establishing finite difference method==&lt;br /&gt;
&lt;br /&gt;
Then the MATLAB code that numerically solves the heat equation posed exposed. It has been solved by the finite difference method with &amp;lt;math&amp;gt; \Delta x = 0.1 &amp;lt;/math&amp;gt; and we have used the method of taking time trapeze &amp;lt;math&amp;gt; \Delta t = \Delta x &amp;lt;/math&amp;gt;. The number of subintervals in which we divide the rod length is &amp;lt;math&amp;gt; Nx = 30 &amp;lt;/math&amp;gt; and time to which we have taken to represent &amp;lt;math&amp;gt; 2 &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
clear all&lt;br /&gt;
%solve the heat equation ut-uxx = 0 with&lt;br /&gt;
% u(0,t)=0 u(l,t)=10 u(x,0)=the piecewise title&lt;br /&gt;
L=3;T=2;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=hx;&lt;br /&gt;
K=(2*diag(ones(1,Nx-1))-diag(ones(1,Nx-2),1)-diag(ones(1,Nx-2),-1))/(hx^2);&lt;br /&gt;
x=hx:hx:L-hx;&lt;br /&gt;
F=zeros(Nx-1,1);F(Nx-1)=10/(hx^2);&lt;br /&gt;
t=0:ht:T;&lt;br /&gt;
u0=10*x/3;u0(10:20)=100;&lt;br /&gt;
uu=u0';&lt;br /&gt;
U(1,:)=[0 u0 10];&lt;br /&gt;
%method of trapezoids&lt;br /&gt;
for n=1:(length(t)-1)&lt;br /&gt;
 uu=(eye(Nx-1)+(ht/2)*K)\(uu+ht*(-K*uu+F+F)/2);&lt;br /&gt;
 U(n+1,:)=[0 uu' 10];&lt;br /&gt;
end&lt;br /&gt;
X=0:hx:L;&lt;br /&gt;
[xx,tt]=meshgrid(X,t);&lt;br /&gt;
m=U(:,16);&lt;br /&gt;
figure(1)&lt;br /&gt;
surf(xx,tt,U)&lt;br /&gt;
xlabel('space')&lt;br /&gt;
ylabel('time')&lt;br /&gt;
zlabel('temperature')&lt;br /&gt;
figure(2)&lt;br /&gt;
plot(t,m)&lt;br /&gt;
xlabel('time')&lt;br /&gt;
ylabel('temperature')&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
In this graph we have shown the 3D surface of the solution of the heat equation posed. As shown, although the trapezoidal method is an implicit method, not well approximated by the points of discontinuity of the initial condition and require less in the discretization step to remove these &amp;quot;peaks&amp;quot; that appear on the surface.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[Archivo: untitled11.jpg|thumb|750px|left|Solution of the heat equation]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the graph shown below the temperature behavior is shown in the middle of the rod with time. This is also obtained from the upper MATLAB code. Comparing the two graphs shows that the latter is a cut &amp;lt;math&amp;gt; x = 1.5 &amp;lt;/math&amp;gt; of the above.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[Archivo: gráfica3a.jpg|thumb|750px|left| u(t) ]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Resolution with different methods =&lt;br /&gt;
&lt;br /&gt;
We will solve the problem initially posed by the implicit and explicit methods by Euler and Runge-Kutta of order 4, following the same steps as with the method of the Trapezium.&lt;br /&gt;
&lt;br /&gt;
==Implicit Euler==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
&lt;br /&gt;
clear all&lt;br /&gt;
%solve the heat equation ut-uxx = 0 with&lt;br /&gt;
% u(0,t)=0 u(l,t)=10 u(x,0)=the piecewise title&lt;br /&gt;
L=3;T=2;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=hx;&lt;br /&gt;
K=(2*diag(ones(1,Nx-1))-diag(ones(1,Nx-2),1)-diag(ones(1,Nx-2),-1))/(hx^2);&lt;br /&gt;
x=hx:hx:L-hx;&lt;br /&gt;
F=zeros(Nx-1,1);F(Nx-1)=10/(hx^2);&lt;br /&gt;
t=0:ht:T;&lt;br /&gt;
u0=10*x/3;u0(10:20)=100;&lt;br /&gt;
uu=u0';&lt;br /&gt;
U(1,:)=[0 u0 10];&lt;br /&gt;
%implicit Euler method&lt;br /&gt;
for n=1:(length(t)-1)&lt;br /&gt;
 uu=(eye(Nx-1)+(ht)*K)\(uu+ht*F);&lt;br /&gt;
 U(n+1,:)=[0 uu' 10];&lt;br /&gt;
end&lt;br /&gt;
X=0:hx:L;&lt;br /&gt;
[xx,tt]=meshgrid(X,t);&lt;br /&gt;
m=U(:,16);&lt;br /&gt;
figure(1)&lt;br /&gt;
surf(xx,tt,U)&lt;br /&gt;
xlabel('space')&lt;br /&gt;
ylabel('time')&lt;br /&gt;
zlabel('temperature')&lt;br /&gt;
figure(2)&lt;br /&gt;
plot(t,m)&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: untitled00010.jpg|thumb|750px|left|Surface with the implicit Euler method]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: Grafica_Euler_impl%C3%ADcito.jpg |thumb|750px|left|&amp;lt;math&amp;gt; x = 1.5 &amp;lt;/math&amp;gt; Graph with the implicit Euler method]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Explicit Euler==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
&lt;br /&gt;
clear all&lt;br /&gt;
% Explicit Euler method&lt;br /&gt;
L=3;T=2;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=(hx^2)/2;% must do so, if not it does not work&lt;br /&gt;
K=(2*diag(ones(1,Nx-1))-diag(ones(1,Nx-2),1)-diag(ones(1,Nx-2),-1))/(hx^2);&lt;br /&gt;
x=hx:hx:L-hx;&lt;br /&gt;
F=zeros(Nx-1,1);F(Nx-1)=10/(hx^2);&lt;br /&gt;
t=0:ht:T;&lt;br /&gt;
u0=10*x/3;u0(10:20)=100;&lt;br /&gt;
uu=u0';&lt;br /&gt;
U(1,:)=[0 u0 10];&lt;br /&gt;
for n=1:(length(t)-1)&lt;br /&gt;
 uu=uu+ht*(-K*uu+F);&lt;br /&gt;
 U(n+1,:)=[0 uu' 10];&lt;br /&gt;
end&lt;br /&gt;
X=0:hx:L;&lt;br /&gt;
[xx,tt]=meshgrid(X,t);&lt;br /&gt;
m=U(:,16);&lt;br /&gt;
figure(3)&lt;br /&gt;
surf(xx,tt,U)&lt;br /&gt;
xlabel('space')&lt;br /&gt;
ylabel('time')&lt;br /&gt;
zlabel('Temperature')&lt;br /&gt;
figure(4)&lt;br /&gt;
plot(t,m)&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: untitled9.jpg|thumb|750px|left|Surface with explicit Euler method ]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: Euler1.3.jpg |thumb|750px|left|Graph in &amp;lt;math&amp;gt;x=1.5&amp;lt;/math&amp;gt; with explicit Euler method]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Runge-Kutta==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
&lt;br /&gt;
clear all&lt;br /&gt;
% Runge Kutta method&lt;br /&gt;
L=3;T=2;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=(hx^2)/2;% if we do not add ht it does not work&lt;br /&gt;
K=(2*diag(ones(1,Nx-1))-diag(ones(1,Nx-2),1)-diag(ones(1,Nx-2),-1))/(hx^2);&lt;br /&gt;
x=hx:hx:L-hx;&lt;br /&gt;
F=zeros(Nx-1,1);F(Nx-1)=10/(hx^2);&lt;br /&gt;
t=0:ht:T;&lt;br /&gt;
u0=10*x/3;u0(10:20)=100;&lt;br /&gt;
uu=u0';&lt;br /&gt;
U(1,:)=[0 u0 10];&lt;br /&gt;
for n=1:(length(t)-1)&lt;br /&gt;
 k1=-K*uu+F;&lt;br /&gt;
 k2=-K*(uu+k1*ht/2)+F;&lt;br /&gt;
 k3=-K*(uu+k2*ht/2)+F;&lt;br /&gt;
 k4=-K*(uu+k3*ht)+F;&lt;br /&gt;
 uu=uu+(ht/6)*(k1+2*k2+2*k3+k4);&lt;br /&gt;
 U(n+1,:)=[0 uu' 10];&lt;br /&gt;
end&lt;br /&gt;
X=0:hx:L;&lt;br /&gt;
[xx,tt]=meshgrid(X,t);&lt;br /&gt;
m=U(:,16);&lt;br /&gt;
figure(5)&lt;br /&gt;
surf(xx,tt,U)&lt;br /&gt;
xlabel('space')&lt;br /&gt;
ylabel('time')&lt;br /&gt;
zlabel('Temperature')&lt;br /&gt;
figure(6)&lt;br /&gt;
plot(t,m)&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: untitled8.jpg|thumb|750px|left|Surface with Runge Kutta method]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: Grafica_Runge_Kutta.jpeg|thumb|750px|left|Graph in &amp;lt;math&amp;gt;x=1.5&amp;lt;/math&amp;gt; Runge Kutta method]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can see that the method that works best is the implicit Euler, whereas explicit Euler and Runge-Kutta, being explicit methods require a rodent control into smaller intervals, and still not a good approximation is achieved as can be seen in the graph of the explicit Euler method. Therefore, for what follows, we use implicit Euler method.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Stationary state=&lt;br /&gt;
&lt;br /&gt;
It is said that a physical system is in stationary state when its characteristics do not vary with time. In this section we address this stationary state, which consists of neglecting the time and see what happens to our problem without taking into account the time variable.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;u_t(x,t)\approx 0; \ u_{xx}=0; \ u_x=c_1(t); \ u=c_1(t)x+c_2(t)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Substituting the boundary conditions:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;u(0)=0; \ c_2(t)=0; \ u(3)=10; \ c_1(t)=\frac{10}{3}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Thus the stationary solution is &amp;lt;math&amp;gt;u(x,t)=\frac{10x}{3}&amp;lt;/math&amp;gt;, which is related to the initial condition. It seems logical that once the temperature in the center of the rod has dissipated, the ends having this constant temperature varies linearly between the two.&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
&lt;br /&gt;
clear all&lt;br /&gt;
%solve the heat equation ut-uxx = 0 with&lt;br /&gt;
% u(0,t)=0 u(l,t)=10 u(x,0)=the piecewise title&lt;br /&gt;
L=3;T=10;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=hx;&lt;br /&gt;
K=(2*diag(ones(1,Nx-1))-diag(ones(1,Nx-2),1)-diag(ones(1,Nx-2),-1))/(hx^2);&lt;br /&gt;
x=hx:hx:L-hx;&lt;br /&gt;
F=zeros(Nx-1,1);F(Nx-1)=10/(hx^2);&lt;br /&gt;
t=0:ht:T;&lt;br /&gt;
u0=10*x/3;u0(10:20)=100;&lt;br /&gt;
uu=u0';&lt;br /&gt;
U(1,:)=[0 u0 10];&lt;br /&gt;
%método de Euler implícito&lt;br /&gt;
for n=1:(length(t)-1)&lt;br /&gt;
 uu=(eye(Nx-1)+(ht)*K)\(uu+ht*F);&lt;br /&gt;
 U(n+1,:)=[0 uu' 10];&lt;br /&gt;
end&lt;br /&gt;
X=0:hx:L;&lt;br /&gt;
[xx,tt]=meshgrid(X,t);&lt;br /&gt;
%solución estacionaria u(x)=10/3*x&lt;br /&gt;
V=10*xx/3;&lt;br /&gt;
figure(1)&lt;br /&gt;
hold on&lt;br /&gt;
surf(xx,tt,U)&lt;br /&gt;
xlabel('space')&lt;br /&gt;
ylabel('time')&lt;br /&gt;
zlabel('Temperature')&lt;br /&gt;
h1=surf(xx,tt,V),set(h1,'FaceColor','magenta','FaceAlpha',0.5,'EdgeColor','w')&lt;br /&gt;
hold off&lt;br /&gt;
t0=U(1,:);t1=U(1/ht+1,:);t2=U(2/ht+1,:);t10=U(10/ht+1,:);&lt;br /&gt;
figure(2)&lt;br /&gt;
subplot(2,2,1)&lt;br /&gt;
hold on&lt;br /&gt;
plot(X,t0)&lt;br /&gt;
plot(X,V(1,:),'r')&lt;br /&gt;
xlabel('x')&lt;br /&gt;
ylabel('temperature with t=0')&lt;br /&gt;
hold off&lt;br /&gt;
subplot(2,2,2)&lt;br /&gt;
hold on&lt;br /&gt;
plot(X,t1)&lt;br /&gt;
plot(X,V(1+1/ht,:),'r')&lt;br /&gt;
xlabel('x')&lt;br /&gt;
ylabel('temperature with t=1')&lt;br /&gt;
hold off&lt;br /&gt;
subplot(2,2,3)&lt;br /&gt;
hold on&lt;br /&gt;
plot(X,t2)&lt;br /&gt;
plot(X,V(1+2/ht,:),'r')&lt;br /&gt;
xlabel('x')&lt;br /&gt;
ylabel('temperature with t=2')&lt;br /&gt;
hold off&lt;br /&gt;
subplot(2,2,4)&lt;br /&gt;
hold on&lt;br /&gt;
plot(X,t10)&lt;br /&gt;
plot(X,V(1+10/ht,:),'r')&lt;br /&gt;
xlabel('x')&lt;br /&gt;
ylabel('temperature with t=10')&lt;br /&gt;
hold off&lt;br /&gt;
figure(3)&lt;br /&gt;
subplot(2,2,1)&lt;br /&gt;
e1=abs(t0-V(1,:));me1=max(e1);...&lt;br /&gt;
sprintf('The maximum difference with the stationary solution in t=0 is %d .',me1)&lt;br /&gt;
plot(X,e1,'g'),xlabel('x'),...&lt;br /&gt;
ylabel('Difference with the stationary solution in t=0') &lt;br /&gt;
subplot(2,2,2)&lt;br /&gt;
e2=abs(t1-V(1+1/ht,:));me2=max(e2);...&lt;br /&gt;
sprintf('The maximum difference with the stationary solution in t=1 is %d .',me2)&lt;br /&gt;
plot(X,e2,'g'),xlabel('x'),...&lt;br /&gt;
ylabel('Difference with the stationary solution t=1') &lt;br /&gt;
subplot(2,2,3)&lt;br /&gt;
e3=abs(t2-V(1+2/ht,:));me3=max(e3);...&lt;br /&gt;
sprintf('The maximum difference with the stationary solution in t=2 is %d .',me3)&lt;br /&gt;
plot(X,e3,'g'),xlabel('x'),...&lt;br /&gt;
ylabel('Difference with the stationary solution in t=2') &lt;br /&gt;
subplot(2,2,4)&lt;br /&gt;
e4=abs(t10-V(1+10/ht,:));me4=max(e4);...&lt;br /&gt;
sprintf('The maximum difference with the stationary solution in t=10 is %d .',me4)&lt;br /&gt;
plot(X,e4,'g'),xlabel('x'),ylabel('Difference with the stationary solution in t=10') &lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: untitled7.jpg|thumb|750px|left|Real surfaces and the stationary solution (in pink)]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This second graph shows as as we move in time (t older) solving our heat equation (blue) is more assimilated to the (red) stationary solution.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: untitled5.jpg|thumb|750px|left|Comparing solutions in &amp;lt;math&amp;gt;t=0,1,2,10&amp;lt;/math&amp;gt;]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
We now show the difference between the previous two solutions stationary real and represented throughout the rod for different values of time. We see how to increasingly large time difference between the two is narrowing, observing the order of magnitude in the ordinate.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: untitled6.jpg|thumb|750px|left|Differences with the stationary solution &amp;lt;math&amp;gt;t=0,1,2,10&amp;lt;/math&amp;gt; order]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Neumann type boundary condition=&lt;br /&gt;
&lt;br /&gt;
Now let's consider a different boundary condition at the right end. Instead of assuming a constant temperature at that end as above, we will place on it an insulating piece. This isolate causes no loss of heat at the right end, that is, the flow temperature is null. This condition is of Neumann type, unlike the previous ones were Dirichlet. So, we keep the condition at the left end and apply the new on the far right, which is&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;-ku_x(3,t)=0 \rightarrow &amp;lt;/math&amp;gt; $\boxed{u_x(3,t)=0}$&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this situation, the temperature of the rod is given by the following problem&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{cases}&lt;br /&gt;
u_t-u_{xx}=0, \qquad x\epsilon(0,3), t&amp;gt;0\\&lt;br /&gt;
u(0,t)=0, u_x(3,t)=0, \qquad t&amp;gt;0\\&lt;br /&gt;
u(x,0)=u_0(x), \qquad x\epsilon[0,3]&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So far in the stationary state for large times the function &amp;lt;math&amp;gt;u(x,t)&amp;lt;/math&amp;gt; that models the temperature of the rod is solution of the following boundary value problem (we call it that because the differential equation depends only &amp;lt;math&amp;gt; x &amp;lt;/math&amp;gt; in the stationary state)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{cases}&lt;br /&gt;
u_{xx}=0, \qquad x\epsilon(0,3), t&amp;gt;0\\&lt;br /&gt;
u(0,t)=0, u_x(3,t)=0, \qquad t&amp;gt;0&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We solve the differential equation to obtain the same result as above&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;u_{xx}=0 \rightarrow u(x,t)=C_1(t)x+C_2(t)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Applying the boundary conditions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;C_1(t)=C_2(t)=0 \rightarrow &amp;lt;/math&amp;gt; $\boxed{u(x,t)=0}$&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This result shows that after a large enough time to consider a steady state in the rod, it acquires a uniform zero temperature. The behavior of the rod is consistent with the boundary conditions, as its final temperature matches that remains constant in the far left.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Finite difference method==&lt;br /&gt;
&lt;br /&gt;
The following image shows an approximation of the problem is shown by the method of finite differences. It can be seen as a high value of the temperature in the rod can be considered constant and uniform throughout, reaching the stationary value &amp;lt;math&amp;gt; u (x, t) = 0 &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo:AP6a.png|thumb|750px|left|Solution of the problem with Neumann type boundary condition]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Specifically, from a time  &amp;lt;math&amp;gt; t = 26.4&amp;lt;/math&amp;gt; we can consider that the temperature reaches stationary value with an error of 0.05, that is, at that moment the difference between the calculated and the thermal distribution stationary takes that value.&lt;br /&gt;
&lt;br /&gt;
Below is reflected Matlab code which approximates the temperature of the rod by using the finite difference method as the implicit Euler that provides a better approximation with a step size  &amp;lt;math&amp;gt; h = 0.1 &amp;lt;/math&amp;gt; in time and space, and &amp;lt;math&amp;gt;t \in \mbox{[0,30]}&amp;lt;/math&amp;gt;. Furthermore, in the instant code approximation value differs 0.05 steady in all parts of the rod is calculated.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
clear all&lt;br /&gt;
%Sixth paragraph of labor&lt;br /&gt;
%solve the heat equation ut-uxx = 0 with&lt;br /&gt;
% U (0, t) = 0 ux (L, t) = 0 u (x, 0) = the function piecewise title&lt;br /&gt;
L=3;T=30;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=2*hx;&lt;br /&gt;
K=(2*diag(ones(1,Nx))-diag(ones(1,Nx-1),1)-diag(ones(1,Nx-1),-1));&lt;br /&gt;
K(Nx,Nx-1)=-2;K=K/(hx^2);&lt;br /&gt;
x=hx:hx:L;&lt;br /&gt;
F=zeros(Nx,1);&lt;br /&gt;
t=0:ht:T;&lt;br /&gt;
u0=10*x/3;u0(10:20)=100;&lt;br /&gt;
uu=u0';&lt;br /&gt;
U(1,:)=[0 u0];&lt;br /&gt;
%metoodo de Euler implicito&lt;br /&gt;
for n=1:(length(t)-1)&lt;br /&gt;
 uu=(eye(Nx)+(ht)*K)\(uu+ht*F);&lt;br /&gt;
 U(n+1,:)=[0 uu'];&lt;br /&gt;
end&lt;br /&gt;
p=0.05*ones(1,length(x)+1);&lt;br /&gt;
for i=1:length(t)&lt;br /&gt;
if min(U(i,:)&amp;lt;=p)==1 &lt;br /&gt;
    break &lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
SOL=t(i)&lt;br /&gt;
X=0:hx:L;&lt;br /&gt;
[xx,tt]=meshgrid(X,t);&lt;br /&gt;
surf(xx,tt,U)&lt;br /&gt;
title('Solution of the problem with Neumann type boundary condition')&lt;br /&gt;
xlabel('Space')&lt;br /&gt;
ylabel('Time')&lt;br /&gt;
zlabel('Temperature')&lt;br /&gt;
p=U(:,Nx+1);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Fourier Method==&lt;br /&gt;
&lt;br /&gt;
We propose now the same problem using the Fourier method. Thus, we seek solutions &amp;lt;math&amp;gt;u(x,t)=\varphi(x)T(t)&amp;lt;/math&amp;gt; form, where &amp;lt;math&amp;gt;\varphi(x)&amp;lt;/math&amp;gt; must satisfy the following problem eigenvalue&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{cases}&lt;br /&gt;
\varphi’’(x)+\lambda\varphi(x)=0\\&lt;br /&gt;
\varphi(0)=0, \varphi’(3)=0&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The solution of the differential equation is &amp;lt;math&amp;gt;\varphi(x)=a\cos(\sqrt{\lambda}x)+b\sin(\sqrt{\lambda}x)&amp;lt;/math&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Applying the boundary conditions we obtain the eigenvalues &amp;lt;math&amp;gt;\mu_k&amp;lt;/math&amp;gt; and eigenfunctions &amp;lt;math&amp;gt;\varphi_k(x)&amp;lt;/math&amp;gt; of the problem&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\varphi(0)=0 \rightarrow a=0&amp;lt;/math&amp;gt;;&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\varphi’(3)=0 \rightarrow \sqrt{\lambda}\,b\cos(\sqrt{\lambda}\,3)=0 \rightarrow \sqrt{\lambda}\,3=(k-{1\over2})\,\pi \rightarrow &amp;lt;/math&amp;gt; $\boxed{\lambda=\mu_k=(k-{1\over2})^2{\pi^2\over9}}$;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;So $\boxed{\varphi_k(x)=\sin(k-{1\over2}){\pi\over3}x}$, &amp;lt;math&amp;gt; \qquad k=1,2,3…N&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If we apply that &amp;lt;math&amp;gt;u_k(x,t)=\varphi_k(x)T_k(t)&amp;lt;/math&amp;gt; satisfies the differential equation &amp;lt;math&amp;gt; u_t-u_{xx}=0&amp;lt;/math&amp;gt;, we obtain the differential equation determines &amp;lt;math&amp;gt;T_k(t)&amp;lt;/math&amp;gt; &amp;lt;center&amp;gt; &amp;lt;math&amp;gt;u_t-u_{xx}=0 \rightarrow \varphi_k(x)T_k’(t)-\varphi_k’’(x)T_k(t)=\varphi_k(x)T_k’(t)-(-\mu_k)\varphi_k(x)T_k(t)=0 \rightarrow&amp;lt;/math&amp;gt; $\boxed{T_k’(t)+\mu_kT_k(t)=0}$&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solution of this differential equation $\boxed{T_k(t)=C_ke^{-\mu_kt}= C_ke^{-(k-{1\over2})^2{\pi^2\over9}t}}$ and therefore &amp;lt;math&amp;gt;u_k(x,t)= \varphi_k(x)T_k(t)=C_ke^{-(k-{1\over2})^2{\pi^2\over9}t}\sin(k-{1\over2}){\pi\over3}x&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If we express the solution of the problem as $\boxed{u (x, t) = \sum_ {k = 1} ^ Nu_k (x, t) = \sum_ {k = 1} ^ N ^ C_ke {- (k-{1 \over2}) ^ 2 {\pi ^ 2 \over9} t} \sin (k-{1 \over2}) {\pi \over3} x}$ and make satisfying the initial condition we obtain &amp;lt;math&amp;gt;u(x,0)=\sum_{k=1}^NC_k\sin(k-{1\over2}){\pi\over3}x&amp;lt;/math&amp;gt;. Thus, by uniqueness of the Fourier coefficients, the coefficients &amp;lt;math&amp;gt; C_K &amp;lt;/math&amp;gt; match those of the Fourier series with respect to the eigenfunctions &amp;lt;math&amp;gt; \varphi_k (x) &amp;lt;/math&amp;gt; Function apart that determines the initial condition (expressed at the beginning of the article).&lt;br /&gt;
&lt;br /&gt;
The problem is thus limited to the calculation of these coefficients according to the expression&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;$\boxed{C_k={\int_{0}^{3}u(x,0)\varphi_k(x)dx\over\int_{0}^{3}\varphi_k^2(x)dx}}$&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The degree of accuracy of the approximation with this method depends on the number of elements in the Fourier series, ie, the value of &amp;lt;math&amp;gt; N &amp;lt;/math&amp;gt;. We study the temperature of the rod taking &amp;lt;math&amp;gt;  N = 1,3,5,10,20 &amp;lt;/math&amp;gt; values, as you can see in the picture below. It can be seen, especially in the initial condition, that as the value of &amp;lt;math&amp;gt; N &amp;lt;/math&amp;gt; is the approximate increase function is closer to the real.&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo:Untitled4.jpg|thumb|750px|left|Solutions with different number of terms of the Fourier series]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
These results can be better taking a compare &amp;lt;math&amp;gt;  t = 0.5 &amp;lt;/math&amp;gt; fixed instant, and representing each function it in the same graph, as we see below. For this case we also added the approximation with 2 terms of the Fourier series to reflect that up to 3 terms approaches can be distinguished, but once this number of elements in the series approximations are virtually indistinguishable when compared on the same graph.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[Archivo:Untitled3.jpg|thumb|750px|left|Graph of temperature in t=0.5 with N terms of the Fourier series]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The following Matlab code which approximates the temperature of the rod by the Fourier method, with N = 1,3,5,10,20 terms of the series, and step size is reflected &amp;lt;math&amp;gt;h=0,1&amp;lt;/math&amp;gt; in time and space, and &amp;lt;math&amp;gt;t \in \mbox{[0,10]}&amp;lt;/math&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
clear all&lt;br /&gt;
%Seventh section of the paper&lt;br /&gt;
% solve the heat equation ut-uxx = 0 with&lt;br /&gt;
% U (0, t) = 0 ux (L, t) = 0 u (x, 0) = the function piecewise title&lt;br /&gt;
% Resolution with fourier&lt;br /&gt;
L=3;T=10;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=hx;&lt;br /&gt;
x=0:hx:L;t=0:ht:T;&lt;br /&gt;
[xx,tt]=meshgrid(x,t);&lt;br /&gt;
q=[1,2,3,5,10,20];&lt;br /&gt;
a=[1,3,5,10,20];&lt;br /&gt;
f=10*x/3;f(11:21)=100;&lt;br /&gt;
i=0;&lt;br /&gt;
for Q=q&lt;br /&gt;
u=0;&lt;br /&gt;
for k=1:Q&lt;br /&gt;
    p=sin((k-1/2)*(pi/3)*x);&lt;br /&gt;
    c=trapz(x,f.*p)/trapz(x,p.*p);&lt;br /&gt;
    u=u+c*exp(-((k-1/2)^2)*((pi/3)^2)*tt).*sin((k-1/2)*(pi/3)*xx);&lt;br /&gt;
end&lt;br /&gt;
b=find(Q==a);&lt;br /&gt;
if b&amp;lt;6&lt;br /&gt;
i=i+1;&lt;br /&gt;
figure(1)&lt;br /&gt;
subplot(2,3,i)&lt;br /&gt;
ca=num2str(Q);r=strcat(['Solution with ',ca,' terms of the Fourier series']);&lt;br /&gt;
if Q==1&lt;br /&gt;
r=strcat(['Solution with ',ca,' term of the Fourier series']);&lt;br /&gt;
end&lt;br /&gt;
surf(xx,tt,u),xlabel('Space'),ylabel('Time'),zlabel('Temperature'),title(r)&lt;br /&gt;
end&lt;br /&gt;
d(find(q==Q),:)=u(0.5/ht+1,:);&lt;br /&gt;
end&lt;br /&gt;
figure(2)&lt;br /&gt;
hold on&lt;br /&gt;
title('Temperature in t=0.5 with N terms of the Fourier series')&lt;br /&gt;
plot(x,d(1:6,:))&lt;br /&gt;
xlabel('Space'),ylabel('Time')&lt;br /&gt;
legend('N=1','N=2','N=3','N=5','N=10','N=20','Location','best')&lt;br /&gt;
hold off&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Losses along the rod=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now we will study the case where there are heat sources or sinks along the rod. Specifically, if there is heat loss through the air having a constant temperature of 16 degrees. With the boundary conditions that we had initially keeping the left and right at 0 and 10 degrees respectively ends, the problem would be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{cases}&lt;br /&gt;
u_t-u_{xx}+u-16=0,\ x \in \mbox{[0,3]} &amp;amp;  t&amp;gt;0 \\&lt;br /&gt;
u(0,t)=0; u(3,t)=10; &amp;amp; u(x,0)=g(x) ;&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;math&amp;gt;g(x)&amp;lt;/math&amp;gt;  is defined as in the first problem:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
u_0=&lt;br /&gt;
\begin{cases}&lt;br /&gt;
10x/3 &amp;amp;  \mbox{si}  &amp;amp;  x \in \mbox{(0,1)} \cup \mbox{(2,3)}   \\&lt;br /&gt;
100     &amp;amp;  \mbox{si}  &amp;amp;   x \in \mbox{(1,2)}   &lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To solve the problem by finite differences with a term in &amp;lt;math&amp;gt; u (x, t) &amp;lt;/math&amp;gt; need to rethink the discretization in space:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{cases}&lt;br /&gt;
u’_n(t)+\frac{-u_{n-1}(t)+2u_n(t)-u_{n+1}(t)}{h^2}+u_n(t)=16&amp;amp;n=1,2,…,N&amp;amp;t&amp;gt;0 \\&lt;br /&gt;
u_0(t)=0 \\&lt;br /&gt;
u_N(t)=10 \\&lt;br /&gt;
u_n(0)=g(x)&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus, the resulting matrices are as follows&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
K=&lt;br /&gt;
\begin{pmatrix}&lt;br /&gt;
 2 &amp;amp; -1 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp; 0 &amp;amp; 0 \\&lt;br /&gt;
 -1 &amp;amp; 2 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp;0 &amp;amp; 0 \\&lt;br /&gt;
 … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … \\&lt;br /&gt;
 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp; -1 &amp;amp; 2 &lt;br /&gt;
\end{pmatrix}&lt;br /&gt;
\frac{1}{h^2}+&lt;br /&gt;
\begin{pmatrix} &lt;br /&gt;
1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp; 0 &amp;amp; 0 \\&lt;br /&gt;
0 &amp;amp; 1 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp;0 &amp;amp; 0 \\&lt;br /&gt;
… &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … \\&lt;br /&gt;
0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp; 0 &amp;amp; 1&lt;br /&gt;
\end{pmatrix}&lt;br /&gt;
&amp;lt;/math&amp;gt;; &amp;lt;math&amp;gt;&lt;br /&gt;
F=&lt;br /&gt;
\begin{pmatrix}&lt;br /&gt;
16+\frac{0}{h^2} \\&lt;br /&gt;
16 \\&lt;br /&gt;
… \\&lt;br /&gt;
16+\frac{10}{h^2} \\&lt;br /&gt;
\end{pmatrix}&lt;br /&gt;
&amp;lt;/math&amp;gt;; &amp;lt;math&amp;gt;&lt;br /&gt;
U=&lt;br /&gt;
\begin{pmatrix}&lt;br /&gt;
u_1 \\&lt;br /&gt;
u_2 \\&lt;br /&gt;
… \\&lt;br /&gt;
u_{N-1} \\&lt;br /&gt;
\end{pmatrix}&lt;br /&gt;
&amp;lt;/math&amp;gt;; &amp;lt;math&amp;gt;&lt;br /&gt;
U^0=&lt;br /&gt;
\begin{pmatrix}&lt;br /&gt;
g(x_1) \\&lt;br /&gt;
g(x_2) \\&lt;br /&gt;
… \\&lt;br /&gt;
g(x_{N-1})&lt;br /&gt;
\end{pmatrix}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this we can move to numerically solve the problem, but we must recalculate the steady state of the despising rod &amp;lt;math&amp;gt;u_t(x,t)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;u_t(x,t)\approx 0; \ u_{xx}-u+16=0; \ u(0)=0 \ u(3)=10&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is nothing more than an ordinary differential equation of 2nd order with constant coefficients, whose solution is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;a(t)e^x+b(t)e^{-x}+16&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;math&amp;gt; a (t) &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; b (t) &amp;lt;/math&amp;gt; are constants to be obtained to replace and solve the system with the boundary conditions, which in our case have let him Matlab resolved (see lines 22 and 23 of the code).&lt;br /&gt;
Now, we turn to numerically solve the problem, with &amp;lt;math&amp;gt;h=0,1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;t \in \mbox{[0,10]}&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
clear all&lt;br /&gt;
%solve the heat equation ut-uxx + u-16 = 0 with&lt;br /&gt;
% U (0, t) = 0 u (l, t) = 10 u (x, 0) = the function to set pieces&lt;br /&gt;
L=3;T=10;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=hx;&lt;br /&gt;
K=(2*diag(ones(1,Nx-1))-diag(ones(1,Nx-2),1)-diag(ones(1,Nx-2),-1))/(hx^2);&lt;br /&gt;
K=K+eye(Nx-1);&lt;br /&gt;
x=hx:hx:L-hx;&lt;br /&gt;
F=16*ones(Nx-1,1);F(Nx-1)=16+10/(hx^2);&lt;br /&gt;
t=0:ht:T;&lt;br /&gt;
u0=10*x/3;u0(10:20)=100;&lt;br /&gt;
uu=u0';&lt;br /&gt;
U(1,:)=[0 u0 10];&lt;br /&gt;
%metoodo de Euler implicito&lt;br /&gt;
for n=1:(length(t)-1)&lt;br /&gt;
 uu=(eye(Nx-1)+(ht)*K)\(uu+ht*F);&lt;br /&gt;
 U(n+1,:)=[0 uu' 10];&lt;br /&gt;
end&lt;br /&gt;
X=0:hx:L;&lt;br /&gt;
[xx,tt]=meshgrid(X,t);&lt;br /&gt;
a=[1 1;exp(3) exp(-3)];b=[-16;-6];d=a\b;&lt;br /&gt;
V=d(1)*exp(xx)+d(2)*exp(-xx)+16*ones(T/ht+1,Nx+1);&lt;br /&gt;
figure(1)&lt;br /&gt;
hold on&lt;br /&gt;
surf(xx,tt,U)&lt;br /&gt;
xlabel('space')&lt;br /&gt;
ylabel('time')&lt;br /&gt;
zlabel('temperature')&lt;br /&gt;
h1=surf(xx,tt,V),set(h1,'FaceColor','red','FaceAlpha',0.5,'EdgeColor','w')&lt;br /&gt;
xlabel('space')&lt;br /&gt;
ylabel('time')&lt;br /&gt;
zlabel('temperature')&lt;br /&gt;
E=abs(U-V);&lt;br /&gt;
e1=E(46:101,Nx/6+1);&lt;br /&gt;
e2=E(46:101,Nx/3+1);&lt;br /&gt;
e3=E(46:101,Nx/2+1);&lt;br /&gt;
e4=E(46:101,2*Nx/3+1);&lt;br /&gt;
e5=E(46:101,5*Nx/6+1);&lt;br /&gt;
figure(3)&lt;br /&gt;
hold on&lt;br /&gt;
plot(t(46:101),e1)&lt;br /&gt;
plot(t(46:101),e2,'r')&lt;br /&gt;
plot(t(46:101),e3,'k')&lt;br /&gt;
plot(t(46:101),e4,'m')&lt;br /&gt;
plot(t(46:101),e5,'c'),legend('Difference in x=0.5','Difference in x=1',...&lt;br /&gt;
'Difference in x=1.5','Difference in x=2','Difference in x=2.5')&lt;br /&gt;
plot(t(46:101),0.001*ones(1,length(t)-45),'g'),xlabel('time'),...&lt;br /&gt;
ylabel('Difference with the stationary solution')&lt;br /&gt;
hold off&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo:Untitled002.jpg|thumb|750px|left|Graph of &amp;lt;math&amp;gt;u(x,t)&amp;lt;/math&amp;gt;  in &amp;lt;math&amp;gt;x \in \mbox{[0,3]};t \in \mbox{[0,10]}&amp;lt;/math&amp;gt;. In pink is the stationary solution. ]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
As shown in the graph, the actual solution and stationary are virtually identical for &amp;lt;math&amp;gt;  t&amp;gt; 2 &amp;lt;/math&amp;gt;. Furthermore we see that near &amp;lt;math&amp;gt; t = 5 &amp;lt;/math&amp;gt; the stationary solution is above the real solution. This is best seen in the following graph in which are represented the difference between the actual solution and the stationary for different values of &amp;lt;math&amp;gt;  x &amp;lt;/math&amp;gt;, namely &amp;lt;math&amp;gt;x = 0.5,1,1.5,2,2.5  &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo:Dif7.jpg|thumb|750px|left|Graph with the difference between the real and the stationary solution for&amp;lt;math&amp;gt;t \in \mbox{[4.5,10]}&amp;lt;/math&amp;gt; ]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
At that point cut the difference between the two is minimal, below &amp;lt;math&amp;gt; 10 ^ {-3 } &amp;lt;/math&amp;gt;, while from there this difference increases slightly and remained constant when time is increasing. This was expected, since for large times the solution of the equation is stationary, and therefore effects of time we have is the difference between two constants. The existing small difference between the two may be because logically, does not disclose exact thing but we are solving the equation numerically.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Changing the boundary conditions==&lt;br /&gt;
&lt;br /&gt;
Suppose now that we change the boundary conditions, so that now the left end of the rod to be in contact with a material whose temperature varies according to the function &amp;lt;math&amp;gt; 10sen (t) &amp;lt;/math&amp;gt;, and by the end right there is a flow of constant heat input &amp;lt;math&amp;gt; 1 &amp;lt;/math&amp;gt;. These conditions translate as &amp;lt;math&amp;gt; u (0, t) = 10sen (t) &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; u_x (3, t) = 1 &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
As the second condition of Neumann type, size of the matrices increases one unit, to be known &amp;lt;math&amp;gt; u_n &amp;lt;/math&amp;gt; term. Also &amp;lt;math&amp;gt; K &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; F &amp;lt;/math&amp;gt; change their terms, becoming&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
K=&lt;br /&gt;
\begin{pmatrix}&lt;br /&gt;
 2 &amp;amp; -1 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp; 0 &amp;amp; 0 \\&lt;br /&gt;
 -1 &amp;amp; 2 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp;0 &amp;amp; 0 \\&lt;br /&gt;
 … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … \\&lt;br /&gt;
 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp; -2 &amp;amp; 2 &lt;br /&gt;
\end{pmatrix}&lt;br /&gt;
\frac{1}{h^2}+&lt;br /&gt;
\begin{pmatrix} &lt;br /&gt;
1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp; 0 &amp;amp; 0 \\&lt;br /&gt;
0 &amp;amp; 1 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp;0 &amp;amp; 0 \\&lt;br /&gt;
… &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … \\&lt;br /&gt;
0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp; 0 &amp;amp; 1&lt;br /&gt;
\end{pmatrix}&lt;br /&gt;
&amp;lt;/math&amp;gt;; &amp;lt;math&amp;gt;&lt;br /&gt;
F=&lt;br /&gt;
\begin{pmatrix}&lt;br /&gt;
16+\frac{10sen(t_n)}{h^2} \\&lt;br /&gt;
16 \\&lt;br /&gt;
… \\&lt;br /&gt;
16+\frac{2}{h} \\&lt;br /&gt;
\end{pmatrix}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We solve the implicit Euler method with &amp;lt;math&amp;gt;h=0,1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;t \in \mbox{[0,10]}&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
clear all&lt;br /&gt;
%solve the heat equation ut-uxx + u-16 = 0 with&lt;br /&gt;
% U (0, t) = 10 * sin (t) ux (L, t) = 1 u (x, 0) = the function piecewise title&lt;br /&gt;
L=3;T=10;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=hx;&lt;br /&gt;
K=(2*diag(ones(1,Nx))-diag(ones(1,Nx-1),1)-diag(ones(1,Nx-1),-1));K(Nx,Nx-1)=-2;K=K/(hx^2);&lt;br /&gt;
K=K+eye(Nx);&lt;br /&gt;
x=hx:hx:L;&lt;br /&gt;
t=0:ht:T;&lt;br /&gt;
u0=10*x/3;u0(10:20)=100;&lt;br /&gt;
uu=u0';&lt;br /&gt;
g=10*sin(t);&lt;br /&gt;
U(1,:)=[g(1) u0];&lt;br /&gt;
%implicit Euler method&lt;br /&gt;
for n=1:(length(t)-1)&lt;br /&gt;
   F=16*ones(Nx,1);F(Nx)=16+2/hx;F(1)=16+g(n)/(hx^2);&lt;br /&gt;
   uu=(eye(Nx)+(ht)*K)\(uu+ht*F);&lt;br /&gt;
   U(n+1,:)=[g(n+1) uu'];&lt;br /&gt;
end&lt;br /&gt;
X=0:hx:L;&lt;br /&gt;
[xx,tt]=meshgrid(X,t);&lt;br /&gt;
figure(1)&lt;br /&gt;
surf(xx,tt,U)&lt;br /&gt;
xlabel('space')&lt;br /&gt;
ylabel('time')&lt;br /&gt;
zlabel('Temperature')&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo:untitled.jpg|thumb|750px|left|Graph of &amp;lt;math&amp;gt;u(x,t)&amp;lt;/math&amp;gt;  in &amp;lt;math&amp;gt;x \in \mbox{[0,3]};t \in \mbox{[0,10]}&amp;lt;/math&amp;gt; ]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In view of the graph we can conclude that as previously when we had a Neumann type condition, the heat &amp;quot;escapes&amp;quot; from the left end at a variable temperature with time while entering from the right. This can be seen if the program is run on the graph by observing the slight slope that the surface of temperatures has at the left side.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Categoría:Ecuaciones Diferenciales]]&lt;br /&gt;
[[Categoría:ED13/14]]&lt;br /&gt;
[[Categoría:Trabajos 2013-14]]&lt;/div&gt;</summary>
		<author><name>Marino Rivera</name></author>	</entry>

	<entry>
		<id>https://mat.caminos.upm.es/w/index.php?title=Heat_equation_(Grupo_1B)&amp;diff=13569</id>
		<title>Heat equation (Grupo 1B)</title>
		<link rel="alternate" type="text/html" href="https://mat.caminos.upm.es/w/index.php?title=Heat_equation_(Grupo_1B)&amp;diff=13569"/>
				<updated>2014-05-20T15:39:12Z</updated>
		
		<summary type="html">&lt;p&gt;Marino Rivera: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ TrabajoED |Heat equation. Grupo 1-B | [[:Categoría:Ecuaciones Diferenciales|Ecuaciones Diferenciales]]|[[:Categoría:ED13/14|Curso 2013-14]] | Sandro Andrés Martínez &lt;br /&gt;
 &lt;br /&gt;
David Ayala Díez &lt;br /&gt;
 &lt;br /&gt;
Claudia Cózar Coarasa  &lt;br /&gt;
&lt;br /&gt;
Lorena de la Fuente Sanz  &lt;br /&gt;
&lt;br /&gt;
Marino Rivera Muñoz &lt;br /&gt;
  &lt;br /&gt;
José Manuel Torres Serrano }}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this work we have studied the modeling of the heat equation, according to Fourier's law discovered in the nineteenth century.&lt;br /&gt;
&lt;br /&gt;
= Well proposed problem  =&lt;br /&gt;
&lt;br /&gt;
[[Archivo:Nueva imagen.png|thumb|300px|left| Thin rod of length L]]&lt;br /&gt;
&lt;br /&gt;
We will raise the system of equations that satisfies &amp;lt;math&amp;gt;u(x,t)&amp;lt;/math&amp;gt; assuming that the temperature of the rod &amp;lt;math&amp;gt;u(x,t)&amp;lt;/math&amp;gt; satisfies the heat equation &amp;lt;math&amp;gt;u_t-u_{xx}=0&amp;lt;/math&amp;gt;. First, we have a thin, homogeneous and thermally isolated by its lateral surface rod of length  &amp;lt;math&amp;gt;L=3&amp;lt;/math&amp;gt;. At its left end the rod is in contact with a material whose temperature is maintained at 0°C, while the right is in contact with the material at 10°C. We also know that at the initial moment, the temperature distribution follows the &amp;lt;math&amp;gt;u(x,0)=u_0(x)&amp;lt;/math&amp;gt; function specified below. Assuming a standard &amp;lt;math&amp;gt;c=\rho=k=1&amp;lt;/math&amp;gt; parameters and there are no heat sources or sinks along the rod, the problem we have to solve is:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;math&amp;gt;&lt;br /&gt;
(P)&lt;br /&gt;
\begin{cases}&lt;br /&gt;
u_t-u_{xx}=0, \qquad x\epsilon(0,3), t&amp;gt;0\\&lt;br /&gt;
u(0,t)=0, u(3,t)=10, \qquad t&amp;gt;0\\&lt;br /&gt;
u(x,0)=u_0(x), \qquad x\epsilon[0,3]&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
:&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
u_0(x)=&lt;br /&gt;
\begin{cases}&lt;br /&gt;
10x/3 &amp;amp;  \mbox{si}  &amp;amp;  x \in \mbox{(0,1)}\cup\mbox{(2,3)}   \\&lt;br /&gt;
100     &amp;amp;  \mbox{si}  &amp;amp;   x \in \mbox{(1,2)}   &lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Then we will define what is a well proposed problem is one that meets the following:&lt;br /&gt;
&lt;br /&gt;
•	Existence: problem &amp;lt;math&amp;gt;(P)&amp;lt;/math&amp;gt; admits a solution &amp;lt;math&amp;gt;u(x,t)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
•	Uniqueness: if there is a solution &amp;lt;math&amp;gt;(P)&amp;lt;/math&amp;gt; it has to be unique.&lt;br /&gt;
&lt;br /&gt;
•	Stability with respect to initial data: &lt;br /&gt;
We consider the problem:&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
(P_1)&lt;br /&gt;
\begin{cases}&lt;br /&gt;
u_t-u_{xx}=0, \qquad x\epsilon(0,3), t&amp;gt;0\\&lt;br /&gt;
u(0,t)=0, u(3,t)=10, \qquad t&amp;gt;0\\&lt;br /&gt;
u(x,0)=h(x), \qquad x\epsilon[0,3]&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Be &amp;lt;math&amp;gt;u(x,t)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;u_1(x,t)&amp;lt;/math&amp;gt; &amp;lt;math&amp;gt;(P)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;(P_1)&amp;lt;/math&amp;gt; solutions respectively. We say that the &amp;lt;math&amp;gt;(P)&amp;lt;/math&amp;gt; problem is stable with respect to initial data if we prove the inequality of type &amp;lt;math&amp;gt;sup_{(x,t)\in [0,3]x[0,\infty]}\left|u(x,t)-u_1(x,t)\right|\leq Csup_{(x,t)\in [0,3]x[0,\infty]}\left|u_0(x)-h(x)\right|&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; absolute, constant independent of the &amp;lt;math&amp;gt;(P)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;(P_1)&amp;lt;/math&amp;gt; problems.&lt;br /&gt;
&lt;br /&gt;
That &amp;lt;math&amp;gt; (P) &amp;lt;/math&amp;gt; is stable with respect to initial data tells us that if &amp;lt;math&amp;gt; h (x) &amp;lt;/math&amp;gt; is close to &amp;lt;math&amp;gt; u_0 (x) &amp;lt;/math&amp;gt; in the sense that &amp;lt;math&amp;gt; sup_ {(x, t) \ in [0,3] x [0, \infty]} \left | u_0 (x)-h (x) \right | &amp;lt;/math&amp;gt; is small, then the &amp;lt;math&amp;gt;  u (x, t) &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; u_1 (x, t) &amp;lt;/math&amp;gt; solutions are also nearby.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Resolution establishing finite difference method==&lt;br /&gt;
&lt;br /&gt;
Then the MATLAB code that numerically solves the heat equation posed exposed. It has been solved by the finite difference method with &amp;lt;math&amp;gt; \Delta x = 0.1 &amp;lt;/math&amp;gt; and we have used the method of taking time trapeze &amp;lt;math&amp;gt; \Delta t = \Delta x &amp;lt;/math&amp;gt;. The number of subintervals in which we divide the rod length is &amp;lt;math&amp;gt; Nx = 30 &amp;lt;/math&amp;gt; and time to which we have taken to represent &amp;lt;math&amp;gt; 2 &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
clear all&lt;br /&gt;
%solve the heat equation ut-uxx = 0 with&lt;br /&gt;
% u(0,t)=0 u(l,t)=10 u(x,0)=the piecewise title&lt;br /&gt;
L=3;T=2;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=hx;&lt;br /&gt;
K=(2*diag(ones(1,Nx-1))-diag(ones(1,Nx-2),1)-diag(ones(1,Nx-2),-1))/(hx^2);&lt;br /&gt;
x=hx:hx:L-hx;&lt;br /&gt;
F=zeros(Nx-1,1);F(Nx-1)=10/(hx^2);&lt;br /&gt;
t=0:ht:T;&lt;br /&gt;
u0=10*x/3;u0(10:20)=100;&lt;br /&gt;
uu=u0';&lt;br /&gt;
U(1,:)=[0 u0 10];&lt;br /&gt;
%method of trapezoids&lt;br /&gt;
for n=1:(length(t)-1)&lt;br /&gt;
 uu=(eye(Nx-1)+(ht/2)*K)\(uu+ht*(-K*uu+F+F)/2);&lt;br /&gt;
 U(n+1,:)=[0 uu' 10];&lt;br /&gt;
end&lt;br /&gt;
X=0:hx:L;&lt;br /&gt;
[xx,tt]=meshgrid(X,t);&lt;br /&gt;
m=U(:,16);&lt;br /&gt;
figure(1)&lt;br /&gt;
surf(xx,tt,U)&lt;br /&gt;
xlabel('space')&lt;br /&gt;
ylabel('time')&lt;br /&gt;
zlabel('temperature')&lt;br /&gt;
figure(2)&lt;br /&gt;
plot(t,m)&lt;br /&gt;
xlabel('time')&lt;br /&gt;
ylabel('temperature')&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
In this graph we have shown the 3D surface of the solution of the heat equation posed. As shown, although the trapezoidal method is an implicit method, not well approximated by the points of discontinuity of the initial condition and require less in the discretization step to remove these &amp;quot;peaks&amp;quot; that appear on the surface.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[Archivo: untitled11.jpg|thumb|750px|left|Solution of the heat equation]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the graph shown below the temperature behavior is shown in the middle of the rod with time. This is also obtained from the upper MATLAB code. Comparing the two graphs shows that the latter is a cut &amp;lt;math&amp;gt; x = 1.5 &amp;lt;/math&amp;gt; of the above.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[Archivo: gráfica3a.jpg|thumb|750px|left| u(t) ]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Resolution with different methods =&lt;br /&gt;
&lt;br /&gt;
We will solve the problem initially posed by the implicit and explicit methods by Euler and Runge-Kutta of order 4, following the same steps as with the method of the Trapezium.&lt;br /&gt;
&lt;br /&gt;
==Implicit Euler==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
&lt;br /&gt;
clear all&lt;br /&gt;
%solve the heat equation ut-uxx = 0 with&lt;br /&gt;
% u(0,t)=0 u(l,t)=10 u(x,0)=the piecewise title&lt;br /&gt;
L=3;T=2;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=hx;&lt;br /&gt;
K=(2*diag(ones(1,Nx-1))-diag(ones(1,Nx-2),1)-diag(ones(1,Nx-2),-1))/(hx^2);&lt;br /&gt;
x=hx:hx:L-hx;&lt;br /&gt;
F=zeros(Nx-1,1);F(Nx-1)=10/(hx^2);&lt;br /&gt;
t=0:ht:T;&lt;br /&gt;
u0=10*x/3;u0(10:20)=100;&lt;br /&gt;
uu=u0';&lt;br /&gt;
U(1,:)=[0 u0 10];&lt;br /&gt;
%implicit Euler method&lt;br /&gt;
for n=1:(length(t)-1)&lt;br /&gt;
 uu=(eye(Nx-1)+(ht)*K)\(uu+ht*F);&lt;br /&gt;
 U(n+1,:)=[0 uu' 10];&lt;br /&gt;
end&lt;br /&gt;
X=0:hx:L;&lt;br /&gt;
[xx,tt]=meshgrid(X,t);&lt;br /&gt;
m=U(:,16);&lt;br /&gt;
figure(1)&lt;br /&gt;
surf(xx,tt,U)&lt;br /&gt;
xlabel('space')&lt;br /&gt;
ylabel('time')&lt;br /&gt;
zlabel('temperature')&lt;br /&gt;
figure(2)&lt;br /&gt;
plot(t,m)&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: untitled00010.jpg|thumb|750px|left|Surface with the implicit Euler method]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: Grafica_Euler_impl%C3%ADcito.jpg |thumb|750px|left|&amp;lt;math&amp;gt; x = 1.5 &amp;lt;/math&amp;gt; Graph with the implicit Euler method]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Explicit Euler==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
&lt;br /&gt;
clear all&lt;br /&gt;
% Explicit Euler method&lt;br /&gt;
L=3;T=2;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=(hx^2)/2;% must do so, if not it does not work&lt;br /&gt;
K=(2*diag(ones(1,Nx-1))-diag(ones(1,Nx-2),1)-diag(ones(1,Nx-2),-1))/(hx^2);&lt;br /&gt;
x=hx:hx:L-hx;&lt;br /&gt;
F=zeros(Nx-1,1);F(Nx-1)=10/(hx^2);&lt;br /&gt;
t=0:ht:T;&lt;br /&gt;
u0=10*x/3;u0(10:20)=100;&lt;br /&gt;
uu=u0';&lt;br /&gt;
U(1,:)=[0 u0 10];&lt;br /&gt;
for n=1:(length(t)-1)&lt;br /&gt;
 uu=uu+ht*(-K*uu+F);&lt;br /&gt;
 U(n+1,:)=[0 uu' 10];&lt;br /&gt;
end&lt;br /&gt;
X=0:hx:L;&lt;br /&gt;
[xx,tt]=meshgrid(X,t);&lt;br /&gt;
m=U(:,16);&lt;br /&gt;
figure(3)&lt;br /&gt;
surf(xx,tt,U)&lt;br /&gt;
xlabel('space')&lt;br /&gt;
ylabel('time')&lt;br /&gt;
zlabel('Temperature')&lt;br /&gt;
figure(4)&lt;br /&gt;
plot(t,m)&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: untitled9.jpg|thumb|750px|left|Surface with explicit Euler method ]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: Euler1.3.jpg |thumb|750px|left|Graph in &amp;lt;math&amp;gt;x=1.5&amp;lt;/math&amp;gt; with explicit Euler method]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Runge-Kutta==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
&lt;br /&gt;
clear all&lt;br /&gt;
% Runge Kutta method&lt;br /&gt;
L=3;T=2;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=(hx^2)/2;% if we do not add ht it does not work&lt;br /&gt;
K=(2*diag(ones(1,Nx-1))-diag(ones(1,Nx-2),1)-diag(ones(1,Nx-2),-1))/(hx^2);&lt;br /&gt;
x=hx:hx:L-hx;&lt;br /&gt;
F=zeros(Nx-1,1);F(Nx-1)=10/(hx^2);&lt;br /&gt;
t=0:ht:T;&lt;br /&gt;
u0=10*x/3;u0(10:20)=100;&lt;br /&gt;
uu=u0';&lt;br /&gt;
U(1,:)=[0 u0 10];&lt;br /&gt;
for n=1:(length(t)-1)&lt;br /&gt;
 k1=-K*uu+F;&lt;br /&gt;
 k2=-K*(uu+k1*ht/2)+F;&lt;br /&gt;
 k3=-K*(uu+k2*ht/2)+F;&lt;br /&gt;
 k4=-K*(uu+k3*ht)+F;&lt;br /&gt;
 uu=uu+(ht/6)*(k1+2*k2+2*k3+k4);&lt;br /&gt;
 U(n+1,:)=[0 uu' 10];&lt;br /&gt;
end&lt;br /&gt;
X=0:hx:L;&lt;br /&gt;
[xx,tt]=meshgrid(X,t);&lt;br /&gt;
m=U(:,16);&lt;br /&gt;
figure(5)&lt;br /&gt;
surf(xx,tt,U)&lt;br /&gt;
xlabel('space')&lt;br /&gt;
ylabel('time')&lt;br /&gt;
zlabel('Temperature')&lt;br /&gt;
figure(6)&lt;br /&gt;
plot(t,m)&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: untitled8.jpg|thumb|750px|left|Surface with Runge Kutta method]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: Grafica_Runge_Kutta.jpeg|thumb|750px|left|Graph in &amp;lt;math&amp;gt;x=1.5&amp;lt;/math&amp;gt; Runge Kutta method]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can see that the method that works best is the implicit Euler, whereas explicit Euler and Runge-Kutta, being explicit methods require a rodent control into smaller intervals, and still not a good approximation is achieved as can be seen in the graph of the explicit Euler method. Therefore, for what follows, we use implicit Euler method.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Stationary state=&lt;br /&gt;
&lt;br /&gt;
It is said that a physical system is in stationary state when its characteristics do not vary with time. In this section we address this stationary state, which consists of neglecting the time and see what happens to our problem without taking into account the time variable.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;u_t(x,t)\approx 0; \ u_{xx}=0; \ u_x=c_1(t); \ u=c_1(t)x+c_2(t)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Substituting the boundary conditions:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;u(0)=0; \ c_2(t)=0; \ u(3)=10; \ c_1(t)=\frac{10}{3}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Thus the stationary solution is &amp;lt;math&amp;gt;u(x,t)=\frac{10x}{3}&amp;lt;/math&amp;gt;, which is related to the initial condition. It seems logical that once the temperature in the center of the rod has dissipated, the ends having this constant temperature varies linearly between the two.&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
&lt;br /&gt;
clear all&lt;br /&gt;
%solve the heat equation ut-uxx = 0 with&lt;br /&gt;
% u(0,t)=0 u(l,t)=10 u(x,0)=the piecewise title&lt;br /&gt;
L=3;T=10;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=hx;&lt;br /&gt;
K=(2*diag(ones(1,Nx-1))-diag(ones(1,Nx-2),1)-diag(ones(1,Nx-2),-1))/(hx^2);&lt;br /&gt;
x=hx:hx:L-hx;&lt;br /&gt;
F=zeros(Nx-1,1);F(Nx-1)=10/(hx^2);&lt;br /&gt;
t=0:ht:T;&lt;br /&gt;
u0=10*x/3;u0(10:20)=100;&lt;br /&gt;
uu=u0';&lt;br /&gt;
U(1,:)=[0 u0 10];&lt;br /&gt;
%método de Euler implícito&lt;br /&gt;
for n=1:(length(t)-1)&lt;br /&gt;
 uu=(eye(Nx-1)+(ht)*K)\(uu+ht*F);&lt;br /&gt;
 U(n+1,:)=[0 uu' 10];&lt;br /&gt;
end&lt;br /&gt;
X=0:hx:L;&lt;br /&gt;
[xx,tt]=meshgrid(X,t);&lt;br /&gt;
%solución estacionaria u(x)=10/3*x&lt;br /&gt;
V=10*xx/3;&lt;br /&gt;
figure(1)&lt;br /&gt;
hold on&lt;br /&gt;
surf(xx,tt,U)&lt;br /&gt;
xlabel('space')&lt;br /&gt;
ylabel('time')&lt;br /&gt;
zlabel('Temperature')&lt;br /&gt;
h1=surf(xx,tt,V),set(h1,'FaceColor','magenta','FaceAlpha',0.5,'EdgeColor','w')&lt;br /&gt;
hold off&lt;br /&gt;
t0=U(1,:);t1=U(1/ht+1,:);t2=U(2/ht+1,:);t10=U(10/ht+1,:);&lt;br /&gt;
figure(2)&lt;br /&gt;
subplot(2,2,1)&lt;br /&gt;
hold on&lt;br /&gt;
plot(X,t0)&lt;br /&gt;
plot(X,V(1,:),'r')&lt;br /&gt;
xlabel('x')&lt;br /&gt;
ylabel('temperature with t=0')&lt;br /&gt;
hold off&lt;br /&gt;
subplot(2,2,2)&lt;br /&gt;
hold on&lt;br /&gt;
plot(X,t1)&lt;br /&gt;
plot(X,V(1+1/ht,:),'r')&lt;br /&gt;
xlabel('x')&lt;br /&gt;
ylabel('temperature with t=1')&lt;br /&gt;
hold off&lt;br /&gt;
subplot(2,2,3)&lt;br /&gt;
hold on&lt;br /&gt;
plot(X,t2)&lt;br /&gt;
plot(X,V(1+2/ht,:),'r')&lt;br /&gt;
xlabel('x')&lt;br /&gt;
ylabel('temperature with t=2')&lt;br /&gt;
hold off&lt;br /&gt;
subplot(2,2,4)&lt;br /&gt;
hold on&lt;br /&gt;
plot(X,t10)&lt;br /&gt;
plot(X,V(1+10/ht,:),'r')&lt;br /&gt;
xlabel('x')&lt;br /&gt;
ylabel('temperature with t=10')&lt;br /&gt;
hold off&lt;br /&gt;
figure(3)&lt;br /&gt;
subplot(2,2,1)&lt;br /&gt;
e1=abs(t0-V(1,:));me1=max(e1);...&lt;br /&gt;
sprintf('The maximum difference with the stationary solution in t=0 is %d .',me1)&lt;br /&gt;
plot(X,e1,'g'),xlabel('x'),...&lt;br /&gt;
ylabel('Difference with the stationary solution in t=0') &lt;br /&gt;
subplot(2,2,2)&lt;br /&gt;
e2=abs(t1-V(1+1/ht,:));me2=max(e2);...&lt;br /&gt;
sprintf('The maximum difference with the stationary solution in t=1 is %d .',me2)&lt;br /&gt;
plot(X,e2,'g'),xlabel('x'),...&lt;br /&gt;
ylabel('Difference with the stationary solution t=1') &lt;br /&gt;
subplot(2,2,3)&lt;br /&gt;
e3=abs(t2-V(1+2/ht,:));me3=max(e3);...&lt;br /&gt;
sprintf('The maximum difference with the stationary solution in t=2 is %d .',me3)&lt;br /&gt;
plot(X,e3,'g'),xlabel('x'),...&lt;br /&gt;
ylabel('Difference with the stationary solution in t=2') &lt;br /&gt;
subplot(2,2,4)&lt;br /&gt;
e4=abs(t10-V(1+10/ht,:));me4=max(e4);...&lt;br /&gt;
sprintf('The maximum difference with the stationary solution in t=10 is %d .',me4)&lt;br /&gt;
plot(X,e4,'g'),xlabel('x'),ylabel('Difference with the stationary solution in t=10') &lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: untitled7.jpg|thumb|750px|left|Real surfaces and the stationary solution (in pink)]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This second graph shows as as we move in time (t older) solving our heat equation (blue) is more assimilated to the (red) stationary solution.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: untitled5.jpg|thumb|750px|left|Comparing solutions in &amp;lt;math&amp;gt;t=0,1,2,10&amp;lt;/math&amp;gt;]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
We now show the difference between the previous two solutions stationary real and represented throughout the rod for different values of time. We see how to increasingly large time difference between the two is narrowing, observing the order of magnitude in the ordinate.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: untitled6.jpg|thumb|750px|left|Differences with the stationary solution &amp;lt;math&amp;gt;t=0,1,2,10&amp;lt;/math&amp;gt; order]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Neumann type boundary condition=&lt;br /&gt;
&lt;br /&gt;
Now let's consider a different boundary condition at the right end. Instead of assuming a constant temperature at that end as above, we will place on it an insulating piece. This isolate causes no loss of heat at the right end, that is, the flow temperature is null. This condition is of Neumann type, unlike the previous ones were Dirichlet. So, we keep the condition at the left end and apply the new on the far right, which is&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;-ku_x(3,t)=0 \rightarrow &amp;lt;/math&amp;gt; $\boxed{u_x(3,t)=0}$&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this situation, the temperature of the rod is given by the following problem&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{cases}&lt;br /&gt;
u_t-u_{xx}=0, \qquad x\epsilon(0,3), t&amp;gt;0\\&lt;br /&gt;
u(0,t)=0, u_x(3,t)=0, \qquad t&amp;gt;0\\&lt;br /&gt;
u(x,0)=u_0(x), \qquad x\epsilon[0,3]&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So far in the stationary state for large times the function &amp;lt;math&amp;gt;u(x,t)&amp;lt;/math&amp;gt; that models the temperature of the rod is solution of the following boundary value problem (we call it that because the differential equation depends only &amp;lt;math&amp;gt; x &amp;lt;/math&amp;gt; in the stationary state)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{cases}&lt;br /&gt;
u_{xx}=0, \qquad x\epsilon(0,3), t&amp;gt;0\\&lt;br /&gt;
u(0,t)=0, u_x(3,t)=0, \qquad t&amp;gt;0&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We solve the differential equation to obtain the same result as above&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;u_{xx}=0 \rightarrow u(x,t)=C_1(t)x+C_2(t)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Applying the boundary conditions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;C_1(t)=C_2(t)=0 \rightarrow &amp;lt;/math&amp;gt; $\boxed{u(x,t)=0}$&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This result shows that after a large enough time to consider a steady state in the rod, it acquires a uniform zero temperature. The behavior of the rod is consistent with the boundary conditions, as its final temperature matches that remains constant in the far left.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Finite difference method==&lt;br /&gt;
&lt;br /&gt;
The following image shows an approximation of the problem is shown by the method of finite differences. It can be seen as a high value of the temperature in the rod can be considered constant and uniform throughout, reaching the stationary value &amp;lt;math&amp;gt; u (x, t) = 0 &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo:AP6a.png|thumb|750px|left|Solution of the problem with Neumann type boundary condition]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Specifically, from a time  &amp;lt;math&amp;gt; t = 26.4&amp;lt;/math&amp;gt; we can consider that the temperature reaches stationary value with an error of 0.05, that is, at that moment the difference between the calculated and the thermal distribution stationary takes that value.&lt;br /&gt;
&lt;br /&gt;
Below is reflected Matlab code which approximates the temperature of the rod by using the finite difference method as the implicit Euler that provides a better approximation with a step size  &amp;lt;math&amp;gt; h = 0.1 &amp;lt;/math&amp;gt; in time and space, and &amp;lt;math&amp;gt;t \in \mbox{[0,30]}&amp;lt;/math&amp;gt;. Furthermore, in the instant code approximation value differs 0.05 steady in all parts of the rod is calculated.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
clear all&lt;br /&gt;
%Sixth paragraph of labor&lt;br /&gt;
%solve the heat equation ut-uxx = 0 with&lt;br /&gt;
% U (0, t) = 0 ux (L, t) = 0 u (x, 0) = the function piecewise title&lt;br /&gt;
L=3;T=30;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=2*hx;&lt;br /&gt;
K=(2*diag(ones(1,Nx))-diag(ones(1,Nx-1),1)-diag(ones(1,Nx-1),-1));&lt;br /&gt;
K(Nx,Nx-1)=-2;K=K/(hx^2);&lt;br /&gt;
x=hx:hx:L;&lt;br /&gt;
F=zeros(Nx,1);&lt;br /&gt;
t=0:ht:T;&lt;br /&gt;
u0=10*x/3;u0(10:20)=100;&lt;br /&gt;
uu=u0';&lt;br /&gt;
U(1,:)=[0 u0];&lt;br /&gt;
%metoodo de Euler implicito&lt;br /&gt;
for n=1:(length(t)-1)&lt;br /&gt;
 uu=(eye(Nx)+(ht)*K)\(uu+ht*F);&lt;br /&gt;
 U(n+1,:)=[0 uu'];&lt;br /&gt;
end&lt;br /&gt;
p=0.05*ones(1,length(x)+1);&lt;br /&gt;
for i=1:length(t)&lt;br /&gt;
if min(U(i,:)&amp;lt;=p)==1 &lt;br /&gt;
    break &lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
SOL=t(i)&lt;br /&gt;
X=0:hx:L;&lt;br /&gt;
[xx,tt]=meshgrid(X,t);&lt;br /&gt;
surf(xx,tt,U)&lt;br /&gt;
title('Solution of the problem with Neumann type boundary condition')&lt;br /&gt;
xlabel('Space')&lt;br /&gt;
ylabel('Time')&lt;br /&gt;
zlabel('Temperature')&lt;br /&gt;
p=U(:,Nx+1);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Fourier Method==&lt;br /&gt;
&lt;br /&gt;
We propose now the same problem using the Fourier method. Thus, we seek solutions &amp;lt;math&amp;gt;u(x,t)=\varphi(x)T(t)&amp;lt;/math&amp;gt; form, where &amp;lt;math&amp;gt;\varphi(x)&amp;lt;/math&amp;gt; must satisfy the following problem eigenvalue&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{cases}&lt;br /&gt;
\varphi’’(x)+\lambda\varphi(x)=0\\&lt;br /&gt;
\varphi(0)=0, \varphi’(3)=0&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The solution of the differential equation is &amp;lt;math&amp;gt;\varphi(x)=a\cos(\sqrt{\lambda}x)+b\sin(\sqrt{\lambda}x)&amp;lt;/math&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Applying the boundary conditions we obtain the eigenvalues &amp;lt;math&amp;gt;\mu_k&amp;lt;/math&amp;gt; and eigenfunctions &amp;lt;math&amp;gt;\varphi_k(x)&amp;lt;/math&amp;gt; of the problem&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\varphi(0)=0 \rightarrow a=0&amp;lt;/math&amp;gt;;&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\varphi’(3)=0 \rightarrow \sqrt{\lambda}\,b\cos(\sqrt{\lambda}\,3)=0 \rightarrow \sqrt{\lambda}\,3=(k-{1\over2})\,\pi \rightarrow &amp;lt;/math&amp;gt; $\boxed{\lambda=\mu_k=(k-{1\over2})^2{\pi^2\over9}}$;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;So $\boxed{\varphi_k(x)=\sin(k-{1\over2}){\pi\over3}x}$, &amp;lt;math&amp;gt; \qquad k=1,2,3…N&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If we apply that &amp;lt;math&amp;gt;u_k(x,t)=\varphi_k(x)T_k(t)&amp;lt;/math&amp;gt; satisfies the differential equation &amp;lt;math&amp;gt; u_t-u_{xx}=0&amp;lt;/math&amp;gt;, we obtain the differential equation determines &amp;lt;math&amp;gt;T_k(t)&amp;lt;/math&amp;gt; &amp;lt;center&amp;gt; &amp;lt;math&amp;gt;u_t-u_{xx}=0 \rightarrow \varphi_k(x)T_k’(t)-\varphi_k’’(x)T_k(t)=\varphi_k(x)T_k’(t)-(-\mu_k)\varphi_k(x)T_k(t)=0 \rightarrow&amp;lt;/math&amp;gt; $\boxed{T_k’(t)+\mu_kT_k(t)=0}$&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solution of this differential equation $\boxed{T_k(t)=C_ke^{-\mu_kt}= C_ke^{-(k-{1\over2})^2{\pi^2\over9}t}}$ and therefore &amp;lt;math&amp;gt;u_k(x,t)= \varphi_k(x)T_k(t)=C_ke^{-(k-{1\over2})^2{\pi^2\over9}t}\sin(k-{1\over2}){\pi\over3}x&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If we express the solution of the problem as $\boxed{u (x, t) = \sum_ {k = 1} ^ Nu_k (x, t) = \sum_ {k = 1} ^ N ^ C_ke {- (k-{1 \over2}) ^ 2 {\pi ^ 2 \over9} t} \sin (k-{1 \over2}) {\pi \over3} x}$ and make satisfying the initial condition we obtain &amp;lt;math&amp;gt;u(x,0)=\sum_{k=1}^NC_k\sin(k-{1\over2}){\pi\over3}x&amp;lt;/math&amp;gt;. Thus, by uniqueness of the Fourier coefficients, the coefficients &amp;lt;math&amp;gt; C_K &amp;lt;/math&amp;gt; match those of the Fourier series with respect to the eigenfunctions &amp;lt;math&amp;gt; \varphi_k (x) &amp;lt;/math&amp;gt; Function apart that determines the initial condition (expressed at the beginning of the article).&lt;br /&gt;
&lt;br /&gt;
The problem is thus limited to the calculation of these coefficients according to the expression&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;$\boxed{C_k={\int_{0}^{3}u(x,0)\varphi_k(x)dx\over\int_{0}^{3}\varphi_k^2(x)dx}}$&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The degree of accuracy of the approximation with this method depends on the number of elements in the Fourier series, ie, the value of &amp;lt;math&amp;gt; N &amp;lt;/math&amp;gt;. We study the temperature of the rod taking &amp;lt;math&amp;gt;  N = 1,3,5,10,20 &amp;lt;/math&amp;gt; values, as you can see in the picture below. It can be seen, especially in the initial condition, that as the value of &amp;lt;math&amp;gt; N &amp;lt;/math&amp;gt; is the approximate increase function is closer to the real.&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo:Untitled4.jpg|thumb|750px|left|Solutions with different number of terms of the Fourier series]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
These results can be better taking a compare &amp;lt;math&amp;gt;  t = 0.5 &amp;lt;/math&amp;gt; fixed instant, and representing each function it in the same graph, as we see below. For this case we also added the approximation with 2 terms of the Fourier series to reflect that up to 3 terms approaches can be distinguished, but once this number of elements in the series approximations are virtually indistinguishable when compared on the same graph.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[Archivo:Untitled3.jpg|thumb|750px|left|Graph of temperature in t=0.5 with N terms of the Fourier series]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The following Matlab code which approximates the temperature of the rod by the Fourier method, with N = 1,3,5,10,20 terms of the series, and step size is reflected &amp;lt;math&amp;gt;h=0,1&amp;lt;/math&amp;gt; in time and space, and &amp;lt;math&amp;gt;t \in \mbox{[0,10]}&amp;lt;/math&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
clear all&lt;br /&gt;
%Seventh section of the paper&lt;br /&gt;
% solve the heat equation ut-uxx = 0 with&lt;br /&gt;
% U (0, t) = 0 ux (L, t) = 0 u (x, 0) = the function piecewise title&lt;br /&gt;
% Resolution with fourier&lt;br /&gt;
L=3;T=10;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=hx;&lt;br /&gt;
x=0:hx:L;t=0:ht:T;&lt;br /&gt;
[xx,tt]=meshgrid(x,t);&lt;br /&gt;
q=[1,2,3,5,10,20];&lt;br /&gt;
a=[1,3,5,10,20];&lt;br /&gt;
f=10*x/3;f(11:21)=100;&lt;br /&gt;
i=0;&lt;br /&gt;
for Q=q&lt;br /&gt;
u=0;&lt;br /&gt;
for k=1:Q&lt;br /&gt;
    p=sin((k-1/2)*(pi/3)*x);&lt;br /&gt;
    c=trapz(x,f.*p)/trapz(x,p.*p);&lt;br /&gt;
    u=u+c*exp(-((k-1/2)^2)*((pi/3)^2)*tt).*sin((k-1/2)*(pi/3)*xx);&lt;br /&gt;
end&lt;br /&gt;
b=find(Q==a);&lt;br /&gt;
if b&amp;lt;6&lt;br /&gt;
i=i+1;&lt;br /&gt;
figure(1)&lt;br /&gt;
subplot(2,3,i)&lt;br /&gt;
ca=num2str(Q);r=strcat(['Solution with ',ca,' terms of the Fourier series']);&lt;br /&gt;
if Q==1&lt;br /&gt;
r=strcat(['Solution with ',ca,' term of the Fourier series']);&lt;br /&gt;
end&lt;br /&gt;
surf(xx,tt,u),xlabel('Space'),ylabel('Time'),zlabel('Temperature'),title(r)&lt;br /&gt;
end&lt;br /&gt;
d(find(q==Q),:)=u(0.5/ht+1,:);&lt;br /&gt;
end&lt;br /&gt;
figure(2)&lt;br /&gt;
hold on&lt;br /&gt;
title('Temperature in t=0.5 with N terms of the Fourier series')&lt;br /&gt;
plot(x,d(1:6,:))&lt;br /&gt;
xlabel('Space'),ylabel('Time')&lt;br /&gt;
legend('N=1','N=2','N=3','N=5','N=10','N=20','Location','best')&lt;br /&gt;
hold off&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Losses along the rod=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now we will study the case where there are heat sources or sinks along the rod. Specifically, if there is heat loss through the air having a constant temperature of 16 degrees. With the boundary conditions that we had initially keeping the left and right at 0 and 10 degrees respectively ends, the problem would be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{cases}&lt;br /&gt;
u_t-u_{xx}+u-16=0,\ x \in \mbox{[0,3]} &amp;amp;  t&amp;gt;0 \\&lt;br /&gt;
u(0,t)=0; u(3,t)=10; &amp;amp; u(x,0)=g(x) ;&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;math&amp;gt;g(x)&amp;lt;/math&amp;gt;  is defined as in the first problem:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
u_0=&lt;br /&gt;
\begin{cases}&lt;br /&gt;
10x/3 &amp;amp;  \mbox{si}  &amp;amp;  x \in \mbox{(0,1)} \cup \mbox{(2,3)}   \\&lt;br /&gt;
100     &amp;amp;  \mbox{si}  &amp;amp;   x \in \mbox{(1,2)}   &lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To solve the problem by finite differences with a term in &amp;lt;math&amp;gt; u (x, t) &amp;lt;/math&amp;gt; need to rethink the discretization in space:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{cases}&lt;br /&gt;
u’_n(t)+\frac{-u_{n-1}(t)+2u_n(t)-u_{n+1}(t)}{h^2}+u_n(t)=16&amp;amp;n=1,2,…,N&amp;amp;t&amp;gt;0 \\&lt;br /&gt;
u_0(t)=0 \\&lt;br /&gt;
u_N(t)=10 \\&lt;br /&gt;
u_n(0)=g(x)&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus, the resulting matrices are as follows&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
K=&lt;br /&gt;
\begin{pmatrix}&lt;br /&gt;
 2 &amp;amp; -1 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp; 0 &amp;amp; 0 \\&lt;br /&gt;
 -1 &amp;amp; 2 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp;0 &amp;amp; 0 \\&lt;br /&gt;
 … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … \\&lt;br /&gt;
 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp; -1 &amp;amp; 2 &lt;br /&gt;
\end{pmatrix}&lt;br /&gt;
\frac{1}{h^2}+&lt;br /&gt;
\begin{pmatrix} &lt;br /&gt;
1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp; 0 &amp;amp; 0 \\&lt;br /&gt;
0 &amp;amp; 1 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp;0 &amp;amp; 0 \\&lt;br /&gt;
… &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … \\&lt;br /&gt;
0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp; 0 &amp;amp; 1&lt;br /&gt;
\end{pmatrix}&lt;br /&gt;
&amp;lt;/math&amp;gt;; &amp;lt;math&amp;gt;&lt;br /&gt;
F=&lt;br /&gt;
\begin{pmatrix}&lt;br /&gt;
16+\frac{0}{h^2} \\&lt;br /&gt;
16 \\&lt;br /&gt;
… \\&lt;br /&gt;
16+\frac{10}{h^2} \\&lt;br /&gt;
\end{pmatrix}&lt;br /&gt;
&amp;lt;/math&amp;gt;; &amp;lt;math&amp;gt;&lt;br /&gt;
U=&lt;br /&gt;
\begin{pmatrix}&lt;br /&gt;
u_1 \\&lt;br /&gt;
u_2 \\&lt;br /&gt;
… \\&lt;br /&gt;
u_{N-1} \\&lt;br /&gt;
\end{pmatrix}&lt;br /&gt;
&amp;lt;/math&amp;gt;; &amp;lt;math&amp;gt;&lt;br /&gt;
U^0=&lt;br /&gt;
\begin{pmatrix}&lt;br /&gt;
g(x_1) \\&lt;br /&gt;
g(x_2) \\&lt;br /&gt;
… \\&lt;br /&gt;
g(x_{N-1})&lt;br /&gt;
\end{pmatrix}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this we can move to numerically solve the problem, but we must recalculate the steady state of the despising rod &amp;lt;math&amp;gt;u_t(x,t)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;u_t(x,t)\approx 0; \ u_{xx}-u+16=0; \ u(0)=0 \ u(3)=10&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is nothing more than an ordinary differential equation of 2nd order with constant coefficients, whose solution is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;a(t)e^x+b(t)e^{-x}+16&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;math&amp;gt; a (t) &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; b (t) &amp;lt;/math&amp;gt; are constants to be obtained to replace and solve the system with the boundary conditions, which in our case have let him Matlab resolved (see lines 22 and 23 of the code).&lt;br /&gt;
Now, we turn to numerically solve the problem, with &amp;lt;math&amp;gt;h=0,1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;t \in \mbox{[0,10]}&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
clear all&lt;br /&gt;
%solve the heat equation ut-uxx + u-16 = 0 with&lt;br /&gt;
% U (0, t) = 0 u (l, t) = 10 u (x, 0) = the function to set pieces&lt;br /&gt;
L=3;T=10;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=hx;&lt;br /&gt;
K=(2*diag(ones(1,Nx-1))-diag(ones(1,Nx-2),1)-diag(ones(1,Nx-2),-1))/(hx^2);&lt;br /&gt;
K=K+eye(Nx-1);&lt;br /&gt;
x=hx:hx:L-hx;&lt;br /&gt;
F=16*ones(Nx-1,1);F(Nx-1)=16+10/(hx^2);&lt;br /&gt;
t=0:ht:T;&lt;br /&gt;
u0=10*x/3;u0(10:20)=100;&lt;br /&gt;
uu=u0';&lt;br /&gt;
U(1,:)=[0 u0 10];&lt;br /&gt;
%metoodo de Euler implicito&lt;br /&gt;
for n=1:(length(t)-1)&lt;br /&gt;
 uu=(eye(Nx-1)+(ht)*K)\(uu+ht*F);&lt;br /&gt;
 U(n+1,:)=[0 uu' 10];&lt;br /&gt;
end&lt;br /&gt;
X=0:hx:L;&lt;br /&gt;
[xx,tt]=meshgrid(X,t);&lt;br /&gt;
a=[1 1;exp(3) exp(-3)];b=[-16;-6];d=a\b;&lt;br /&gt;
V=d(1)*exp(xx)+d(2)*exp(-xx)+16*ones(T/ht+1,Nx+1);&lt;br /&gt;
figure(1)&lt;br /&gt;
hold on&lt;br /&gt;
surf(xx,tt,U)&lt;br /&gt;
xlabel('space')&lt;br /&gt;
ylabel('time')&lt;br /&gt;
zlabel('temperature')&lt;br /&gt;
h1=surf(xx,tt,V),set(h1,'FaceColor','red','FaceAlpha',0.5,'EdgeColor','w')&lt;br /&gt;
xlabel('space')&lt;br /&gt;
ylabel('time')&lt;br /&gt;
zlabel('temperature')&lt;br /&gt;
E=abs(U-V);&lt;br /&gt;
e1=E(46:101,Nx/6+1);&lt;br /&gt;
e2=E(46:101,Nx/3+1);&lt;br /&gt;
e3=E(46:101,Nx/2+1);&lt;br /&gt;
e4=E(46:101,2*Nx/3+1);&lt;br /&gt;
e5=E(46:101,5*Nx/6+1);&lt;br /&gt;
figure(3)&lt;br /&gt;
hold on&lt;br /&gt;
plot(t(46:101),e1)&lt;br /&gt;
plot(t(46:101),e2,'r')&lt;br /&gt;
plot(t(46:101),e3,'k')&lt;br /&gt;
plot(t(46:101),e4,'m')&lt;br /&gt;
plot(t(46:101),e5,'c'),legend('Difference in x=0.5','Difference in x=1',...&lt;br /&gt;
'Difference in x=1.5','Difference in x=2','Difference in x=2.5')&lt;br /&gt;
plot(t(46:101),0.001*ones(1,length(t)-45),'g'),xlabel('time'),...&lt;br /&gt;
ylabel('Difference with the stationary solution')&lt;br /&gt;
hold off&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo:Untitled002.jpg|thumb|750px|left|Graph of &amp;lt;math&amp;gt;u(x,t)&amp;lt;/math&amp;gt;  in &amp;lt;math&amp;gt;x \in \mbox{[0,3]};t \in \mbox{[0,10]}&amp;lt;/math&amp;gt;. In pink is the stationary solution. ]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
As shown in the graph, the actual solution and stationary are virtually identical for &amp;lt;math&amp;gt;  t&amp;gt; 2 &amp;lt;/math&amp;gt;. Furthermore we see that near &amp;lt;math&amp;gt; t = 5 &amp;lt;/math&amp;gt; the stationary solution is above the real solution. This is best seen in the following graph in which are represented the difference between the actual solution and the stationary for different values of &amp;lt;math&amp;gt;  x &amp;lt;/math&amp;gt;, namely &amp;lt;math&amp;gt;x = 0.5,1,1.5,2,2.5  &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo:Untitled01.jpg|thumb|750px|left|Graph with the difference between the real and the stationary solution for&amp;lt;math&amp;gt;t \in \mbox{[4.5,10]}&amp;lt;/math&amp;gt; ]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
At that point cut the difference between the two is minimal, below &amp;lt;math&amp;gt; 10 ^ {-3 } &amp;lt;/math&amp;gt;, while from there this difference increases slightly and remained constant when time is increasing. This was expected, since for large times the solution of the equation is stationary, and therefore effects of time we have is the difference between two constants. The existing small difference between the two may be because logically, does not disclose exact thing but we are solving the equation numerically.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Changing the boundary conditions==&lt;br /&gt;
&lt;br /&gt;
Suppose now that we change the boundary conditions, so that now the left end of the rod to be in contact with a material whose temperature varies according to the function &amp;lt;math&amp;gt; 10sen (t) &amp;lt;/math&amp;gt;, and by the end right there is a flow of constant heat input &amp;lt;math&amp;gt; 1 &amp;lt;/math&amp;gt;. These conditions translate as &amp;lt;math&amp;gt; u (0, t) = 10sen (t) &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; u_x (3, t) = 1 &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
As the second condition of Neumann type, size of the matrices increases one unit, to be known &amp;lt;math&amp;gt; u_n &amp;lt;/math&amp;gt; term. Also &amp;lt;math&amp;gt; K &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; F &amp;lt;/math&amp;gt; change their terms, becoming&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
K=&lt;br /&gt;
\begin{pmatrix}&lt;br /&gt;
 2 &amp;amp; -1 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp; 0 &amp;amp; 0 \\&lt;br /&gt;
 -1 &amp;amp; 2 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp;0 &amp;amp; 0 \\&lt;br /&gt;
 … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … \\&lt;br /&gt;
 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp; -2 &amp;amp; 2 &lt;br /&gt;
\end{pmatrix}&lt;br /&gt;
\frac{1}{h^2}+&lt;br /&gt;
\begin{pmatrix} &lt;br /&gt;
1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp; 0 &amp;amp; 0 \\&lt;br /&gt;
0 &amp;amp; 1 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp;0 &amp;amp; 0 \\&lt;br /&gt;
… &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … \\&lt;br /&gt;
0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp; 0 &amp;amp; 1&lt;br /&gt;
\end{pmatrix}&lt;br /&gt;
&amp;lt;/math&amp;gt;; &amp;lt;math&amp;gt;&lt;br /&gt;
F=&lt;br /&gt;
\begin{pmatrix}&lt;br /&gt;
16+\frac{10sen(t_n)}{h^2} \\&lt;br /&gt;
16 \\&lt;br /&gt;
… \\&lt;br /&gt;
16+\frac{2}{h} \\&lt;br /&gt;
\end{pmatrix}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We solve the implicit Euler method with &amp;lt;math&amp;gt;h=0,1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;t \in \mbox{[0,10]}&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
clear all&lt;br /&gt;
%solve the heat equation ut-uxx + u-16 = 0 with&lt;br /&gt;
% U (0, t) = 10 * sin (t) ux (L, t) = 1 u (x, 0) = the function piecewise title&lt;br /&gt;
L=3;T=10;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=hx;&lt;br /&gt;
K=(2*diag(ones(1,Nx))-diag(ones(1,Nx-1),1)-diag(ones(1,Nx-1),-1));K(Nx,Nx-1)=-2;K=K/(hx^2);&lt;br /&gt;
K=K+eye(Nx);&lt;br /&gt;
x=hx:hx:L;&lt;br /&gt;
t=0:ht:T;&lt;br /&gt;
u0=10*x/3;u0(10:20)=100;&lt;br /&gt;
uu=u0';&lt;br /&gt;
g=10*sin(t);&lt;br /&gt;
U(1,:)=[g(1) u0];&lt;br /&gt;
%implicit Euler method&lt;br /&gt;
for n=1:(length(t)-1)&lt;br /&gt;
   F=16*ones(Nx,1);F(Nx)=16+2/hx;F(1)=16+g(n)/(hx^2);&lt;br /&gt;
   uu=(eye(Nx)+(ht)*K)\(uu+ht*F);&lt;br /&gt;
   U(n+1,:)=[g(n+1) uu'];&lt;br /&gt;
end&lt;br /&gt;
X=0:hx:L;&lt;br /&gt;
[xx,tt]=meshgrid(X,t);&lt;br /&gt;
figure(1)&lt;br /&gt;
surf(xx,tt,U)&lt;br /&gt;
xlabel('space')&lt;br /&gt;
ylabel('time')&lt;br /&gt;
zlabel('Temperature')&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo:untitled.jpg|thumb|750px|left|Graph of &amp;lt;math&amp;gt;u(x,t)&amp;lt;/math&amp;gt;  in &amp;lt;math&amp;gt;x \in \mbox{[0,3]};t \in \mbox{[0,10]}&amp;lt;/math&amp;gt; ]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In view of the graph we can conclude that as previously when we had a Neumann type condition, the heat &amp;quot;escapes&amp;quot; from the left end at a variable temperature with time while entering from the right. This can be seen if the program is run on the graph by observing the slight slope that the surface of temperatures has at the left side.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Categoría:Ecuaciones Diferenciales]]&lt;br /&gt;
[[Categoría:ED13/14]]&lt;br /&gt;
[[Categoría:Trabajos 2013-14]]&lt;/div&gt;</summary>
		<author><name>Marino Rivera</name></author>	</entry>

	<entry>
		<id>https://mat.caminos.upm.es/w/index.php?title=Heat_equation_(Grupo_1B)&amp;diff=12240</id>
		<title>Heat equation (Grupo 1B)</title>
		<link rel="alternate" type="text/html" href="https://mat.caminos.upm.es/w/index.php?title=Heat_equation_(Grupo_1B)&amp;diff=12240"/>
				<updated>2014-05-18T17:17:08Z</updated>
		
		<summary type="html">&lt;p&gt;Marino Rivera: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ TrabajoED |Heat equation. Grupo 1-B | [[:Categoría:Ecuaciones Diferenciales|Ecuaciones Diferenciales]]|[[:Categoría:ED13/14|Curso 2013-14]] | Sandro Andrés Martínez &lt;br /&gt;
 &lt;br /&gt;
David Ayala Díez &lt;br /&gt;
 &lt;br /&gt;
Claudia Cózar Coarasa  &lt;br /&gt;
&lt;br /&gt;
Lorena de la Fuente Sanz  &lt;br /&gt;
&lt;br /&gt;
Marino Rivera Muñoz &lt;br /&gt;
  &lt;br /&gt;
José Manuel Torres Serrano }}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this work we have studied the modeling of the heat equation, according to Fourier's law discovered in the nineteenth century.&lt;br /&gt;
&lt;br /&gt;
= Well proposed problem  =&lt;br /&gt;
&lt;br /&gt;
[[Archivo:Nueva imagen.png|thumb|300px|left| Thin rod of length L]]&lt;br /&gt;
&lt;br /&gt;
We will raise the system of equations that satisfies &amp;lt;math&amp;gt;u(x,t)&amp;lt;/math&amp;gt; assuming that the temperature of the rod &amp;lt;math&amp;gt;u(x,t)&amp;lt;/math&amp;gt; satisfies the heat equation &amp;lt;math&amp;gt;u_t-u_{xx}=0&amp;lt;/math&amp;gt;. First, we have a thin, homogeneous and thermally isolated by its lateral surface rod of length  &amp;lt;math&amp;gt;L=3&amp;lt;/math&amp;gt;. At its left end the rod is in contact with a material whose temperature is maintained at 0°C, while the right is in contact with the material at 10°C. We also know that at the initial moment, the temperature distribution follows the &amp;lt;math&amp;gt;u(x,0)=u_0(x)&amp;lt;/math&amp;gt; function specified below. Assuming a standard &amp;lt;math&amp;gt;c=\rho=k=1&amp;lt;/math&amp;gt; parameters and there are no heat sources or sinks along the rod, the problem we have to solve is:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;math&amp;gt;&lt;br /&gt;
(P)&lt;br /&gt;
\begin{cases}&lt;br /&gt;
u_t-u_{xx}=0, \qquad x\epsilon(0,3), t&amp;gt;0\\&lt;br /&gt;
u(0,t)=0, u(3,t)=10, \qquad t&amp;gt;0\\&lt;br /&gt;
u(x,0)=u_0(x), \qquad x\epsilon[0,3]&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
:&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
u_0(x)=&lt;br /&gt;
\begin{cases}&lt;br /&gt;
10x/3 &amp;amp;  \mbox{si}  &amp;amp;  x \in \mbox{(0,1)}\cup\mbox{(2,3)}   \\&lt;br /&gt;
100     &amp;amp;  \mbox{si}  &amp;amp;   x \in \mbox{(1,2)}   &lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Then we will define what is a well proposed problem is one that meets the following:&lt;br /&gt;
&lt;br /&gt;
•	Existence: problem &amp;lt;math&amp;gt;(P)&amp;lt;/math&amp;gt; admits a solution &amp;lt;math&amp;gt;u(x,t)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
•	Uniqueness: if there is a solution &amp;lt;math&amp;gt;(P)&amp;lt;/math&amp;gt; it has to be unique.&lt;br /&gt;
&lt;br /&gt;
•	Stability with respect to initial data: &lt;br /&gt;
We consider the problem:&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
(P_1)&lt;br /&gt;
\begin{cases}&lt;br /&gt;
u_t-u_{xx}=0, \qquad x\epsilon(0,3), t&amp;gt;0\\&lt;br /&gt;
u(0,t)=0, u(3,t)=10, \qquad t&amp;gt;0\\&lt;br /&gt;
u(x,0)=h(x), \qquad x\epsilon[0,3]&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Be &amp;lt;math&amp;gt;u(x,t)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;u_1(x,t)&amp;lt;/math&amp;gt; &amp;lt;math&amp;gt;(P)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;(P_1)&amp;lt;/math&amp;gt; solutions respectively. We say that the &amp;lt;math&amp;gt;(P)&amp;lt;/math&amp;gt; problem is stable with respect to initial data if we prove the inequality of type &amp;lt;math&amp;gt;sup_{(x,t)\in [0,3]x[0,\infty]}\left|u(x,t)-u_1(x,t)\right|\leq Csup_{(x,t)\in [0,3]x[0,\infty]}\left|u_0(x)-h(x)\right|&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; absolute, constant independent of the &amp;lt;math&amp;gt;(P)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;(P_1)&amp;lt;/math&amp;gt; problems.&lt;br /&gt;
&lt;br /&gt;
That &amp;lt;math&amp;gt; (P) &amp;lt;/math&amp;gt; is stable with respect to initial data tells us that if &amp;lt;math&amp;gt; h (x) &amp;lt;/math&amp;gt; is close to &amp;lt;math&amp;gt; u_0 (x) &amp;lt;/math&amp;gt; in the sense that &amp;lt;math&amp;gt; sup_ {(x, t) \ in [0,3] x [0, \infty]} \left | u_0 (x)-h (x) \right | &amp;lt;/math&amp;gt; is small, then the &amp;lt;math&amp;gt;  u (x, t) &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; u_1 (x, t) &amp;lt;/math&amp;gt; solutions are also nearby.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Resolution establishing finite difference method==&lt;br /&gt;
&lt;br /&gt;
Then the MATLAB code that numerically solves the heat equation posed exposed. It has been solved by the finite difference method with &amp;lt;math&amp;gt; \Delta x = 0.1 &amp;lt;/math&amp;gt; and we have used the method of taking time trapeze &amp;lt;math&amp;gt; \Delta t = \Delta x &amp;lt;/math&amp;gt;. The number of subintervals in which we divide the rod length is &amp;lt;math&amp;gt; Nx = 30 &amp;lt;/math&amp;gt; and time to which we have taken to represent &amp;lt;math&amp;gt; 2 &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
clear all&lt;br /&gt;
%solve the heat equation ut-uxx = 0 with&lt;br /&gt;
% u(0,t)=0 u(l,t)=10 u(x,0)=the piecewise title&lt;br /&gt;
L=3;T=2;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=hx;&lt;br /&gt;
K=(2*diag(ones(1,Nx-1))-diag(ones(1,Nx-2),1)-diag(ones(1,Nx-2),-1))/(hx^2);&lt;br /&gt;
x=hx:hx:L-hx;&lt;br /&gt;
F=zeros(Nx-1,1);F(Nx-1)=10/(hx^2);&lt;br /&gt;
t=0:ht:T;&lt;br /&gt;
u0=10*x/3;u0(10:20)=100;&lt;br /&gt;
uu=u0';&lt;br /&gt;
U(1,:)=[0 u0 10];&lt;br /&gt;
%method of trapezoids&lt;br /&gt;
for n=1:(length(t)-1)&lt;br /&gt;
 uu=(eye(Nx-1)+(ht/2)*K)\(uu+ht*(-K*uu+F+F)/2);&lt;br /&gt;
 U(n+1,:)=[0 uu' 10];&lt;br /&gt;
end&lt;br /&gt;
X=0:hx:L;&lt;br /&gt;
[xx,tt]=meshgrid(X,t);&lt;br /&gt;
m=U(:,16);&lt;br /&gt;
figure(1)&lt;br /&gt;
surf(xx,tt,U)&lt;br /&gt;
xlabel('space')&lt;br /&gt;
ylabel('time')&lt;br /&gt;
zlabel('temperature')&lt;br /&gt;
figure(2)&lt;br /&gt;
plot(t,m)&lt;br /&gt;
xlabel('time')&lt;br /&gt;
ylabel('temperature')&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
In this graph we have shown the 3D surface of the solution of the heat equation posed. As shown, although the trapezoidal method is an implicit method, not well approximated by the points of discontinuity of the initial condition and require less in the discretization step to remove these &amp;quot;peaks&amp;quot; that appear on the surface.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[Archivo: untitled11.jpg|thumb|750px|left|Solution of the heat equation]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the graph shown below the temperature behavior is shown in the middle of the rod with time. This is also obtained from the upper MATLAB code. Comparing the two graphs shows that the latter is a cut &amp;lt;math&amp;gt; x = 1.5 &amp;lt;/math&amp;gt; of the above.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[Archivo: gráfica3a.jpg|thumb|750px|left| u(t) ]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Resolution with different methods =&lt;br /&gt;
&lt;br /&gt;
We will solve the problem initially posed by the implicit and explicit methods by Euler and Runge-Kutta of order 4, following the same steps as with the method of the Trapezium.&lt;br /&gt;
&lt;br /&gt;
==Implicit Euler==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
&lt;br /&gt;
clear all&lt;br /&gt;
%solve the heat equation ut-uxx = 0 with&lt;br /&gt;
% u(0,t)=0 u(l,t)=10 u(x,0)=the piecewise title&lt;br /&gt;
L=3;T=2;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=hx;&lt;br /&gt;
K=(2*diag(ones(1,Nx-1))-diag(ones(1,Nx-2),1)-diag(ones(1,Nx-2),-1))/(hx^2);&lt;br /&gt;
x=hx:hx:L-hx;&lt;br /&gt;
F=zeros(Nx-1,1);F(Nx-1)=10/(hx^2);&lt;br /&gt;
t=0:ht:T;&lt;br /&gt;
u0=10*x/3;u0(10:20)=100;&lt;br /&gt;
uu=u0';&lt;br /&gt;
U(1,:)=[0 u0 10];&lt;br /&gt;
%implicit Euler method&lt;br /&gt;
for n=1:(length(t)-1)&lt;br /&gt;
 uu=(eye(Nx-1)+(ht)*K)\(uu+ht*F);&lt;br /&gt;
 U(n+1,:)=[0 uu' 10];&lt;br /&gt;
end&lt;br /&gt;
X=0:hx:L;&lt;br /&gt;
[xx,tt]=meshgrid(X,t);&lt;br /&gt;
m=U(:,16);&lt;br /&gt;
figure(1)&lt;br /&gt;
surf(xx,tt,U)&lt;br /&gt;
xlabel('space')&lt;br /&gt;
ylabel('time')&lt;br /&gt;
zlabel('temperature')&lt;br /&gt;
figure(2)&lt;br /&gt;
plot(t,m)&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: untitled00010.jpg|thumb|750px|left|Surface with the implicit Euler method]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: Grafica_Euler_impl%C3%ADcito.jpg |thumb|750px|left|&amp;lt;math&amp;gt; x = 1.5 &amp;lt;/math&amp;gt; Graph with the implicit Euler method]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Explicit Euler==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
&lt;br /&gt;
clear all&lt;br /&gt;
% Explicit Euler method&lt;br /&gt;
L=3;T=2;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=(hx^2)/2;% must do so, if not it does not work&lt;br /&gt;
K=(2*diag(ones(1,Nx-1))-diag(ones(1,Nx-2),1)-diag(ones(1,Nx-2),-1))/(hx^2);&lt;br /&gt;
x=hx:hx:L-hx;&lt;br /&gt;
F=zeros(Nx-1,1);F(Nx-1)=10/(hx^2);&lt;br /&gt;
t=0:ht:T;&lt;br /&gt;
u0=10*x/3;u0(10:20)=100;&lt;br /&gt;
uu=u0';&lt;br /&gt;
U(1,:)=[0 u0 10];&lt;br /&gt;
for n=1:(length(t)-1)&lt;br /&gt;
 uu=uu+ht*(-K*uu+F);&lt;br /&gt;
 U(n+1,:)=[0 uu' 10];&lt;br /&gt;
end&lt;br /&gt;
X=0:hx:L;&lt;br /&gt;
[xx,tt]=meshgrid(X,t);&lt;br /&gt;
m=U(:,16);&lt;br /&gt;
figure(3)&lt;br /&gt;
surf(xx,tt,U)&lt;br /&gt;
xlabel('space')&lt;br /&gt;
ylabel('time')&lt;br /&gt;
zlabel('Temperature')&lt;br /&gt;
figure(4)&lt;br /&gt;
plot(t,m)&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: untitled9.jpg|thumb|750px|left|Surface with explicit Euler method ]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: Euler1.3.jpg |thumb|750px|left|Graph in &amp;lt;math&amp;gt;x=1.5&amp;lt;/math&amp;gt; with explicit Euler method]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Runge-Kutta==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
&lt;br /&gt;
clear all&lt;br /&gt;
% Runge Kutta method&lt;br /&gt;
L=3;T=2;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=(hx^2)/2;% if we do not add ht it does not work&lt;br /&gt;
K=(2*diag(ones(1,Nx-1))-diag(ones(1,Nx-2),1)-diag(ones(1,Nx-2),-1))/(hx^2);&lt;br /&gt;
x=hx:hx:L-hx;&lt;br /&gt;
F=zeros(Nx-1,1);F(Nx-1)=10/(hx^2);&lt;br /&gt;
t=0:ht:T;&lt;br /&gt;
u0=10*x/3;u0(10:20)=100;&lt;br /&gt;
uu=u0';&lt;br /&gt;
U(1,:)=[0 u0 10];&lt;br /&gt;
for n=1:(length(t)-1)&lt;br /&gt;
 k1=-K*uu+F;&lt;br /&gt;
 k2=-K*(uu+k1*ht/2)+F;&lt;br /&gt;
 k3=-K*(uu+k2*ht/2)+F;&lt;br /&gt;
 k4=-K*(uu+k3*ht)+F;&lt;br /&gt;
 uu=uu+(ht/6)*(k1+2*k2+2*k3+k4);&lt;br /&gt;
 U(n+1,:)=[0 uu' 10];&lt;br /&gt;
end&lt;br /&gt;
X=0:hx:L;&lt;br /&gt;
[xx,tt]=meshgrid(X,t);&lt;br /&gt;
m=U(:,16);&lt;br /&gt;
figure(5)&lt;br /&gt;
surf(xx,tt,U)&lt;br /&gt;
xlabel('space')&lt;br /&gt;
ylabel('time')&lt;br /&gt;
zlabel('Temperature')&lt;br /&gt;
figure(6)&lt;br /&gt;
plot(t,m)&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: untitled8.jpg|thumb|750px|left|Surface with Runge Kutta method]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: Grafica_Runge_Kutta.jpeg|thumb|750px|left|Graph in &amp;lt;math&amp;gt;x=1.5&amp;lt;/math&amp;gt; Runge Kutta method]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can see that the method that works best is the implicit Euler, whereas explicit Euler and Runge-Kutta, being explicit methods require a rodent control into smaller intervals, and still not a good approximation is achieved as can be seen in the graph of the explicit Euler method. Therefore, for what follows, we use implicit Euler method.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Stationary state=&lt;br /&gt;
&lt;br /&gt;
It is said that a physical system is in stationary state when its characteristics do not vary with time. In this section we address this stationary state, which consists of neglecting the time and see what happens to our problem without taking into account the time variable.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;u_t(x,t)\approx 0; \ u_{xx}=0; \ u_x=c_1(t) \ u=c_1(t)x+c_2(t)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Substituting the boundary conditions:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;u(0)=0; \ c_2(t)=0; \ u(3)=10; \ c_1(t)=\frac{10}{3}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Thus the stationary solution is &amp;lt;math&amp;gt; u (x, t) = \ frac {10x} {3} &amp;lt;/math&amp;gt;, which is related to the initial condition. It seems logical that once the temperature in the center of the rod has dissipated, the ends having this constant temperature varies linearly between the two.&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
&lt;br /&gt;
clear all&lt;br /&gt;
%solve the heat equation ut-uxx = 0 with&lt;br /&gt;
% u(0,t)=0 u(l,t)=10 u(x,0)=the piecewise title&lt;br /&gt;
L=3;T=10;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=hx;&lt;br /&gt;
K=(2*diag(ones(1,Nx-1))-diag(ones(1,Nx-2),1)-diag(ones(1,Nx-2),-1))/(hx^2);&lt;br /&gt;
x=hx:hx:L-hx;&lt;br /&gt;
F=zeros(Nx-1,1);F(Nx-1)=10/(hx^2);&lt;br /&gt;
t=0:ht:T;&lt;br /&gt;
u0=10*x/3;u0(10:20)=100;&lt;br /&gt;
uu=u0';&lt;br /&gt;
U(1,:)=[0 u0 10];&lt;br /&gt;
%método de Euler implícito&lt;br /&gt;
for n=1:(length(t)-1)&lt;br /&gt;
 uu=(eye(Nx-1)+(ht)*K)\(uu+ht*F);&lt;br /&gt;
 U(n+1,:)=[0 uu' 10];&lt;br /&gt;
end&lt;br /&gt;
X=0:hx:L;&lt;br /&gt;
[xx,tt]=meshgrid(X,t);&lt;br /&gt;
%solución estacionaria u(x)=10/3*x&lt;br /&gt;
V=10*xx/3;&lt;br /&gt;
figure(1)&lt;br /&gt;
hold on&lt;br /&gt;
surf(xx,tt,U)&lt;br /&gt;
xlabel('space')&lt;br /&gt;
ylabel('time')&lt;br /&gt;
zlabel('Temperature')&lt;br /&gt;
h1=surf(xx,tt,V),set(h1,'FaceColor','magenta','FaceAlpha',0.5,'EdgeColor','w')&lt;br /&gt;
hold off&lt;br /&gt;
t0=U(1,:);t1=U(1/ht+1,:);t2=U(2/ht+1,:);t10=U(10/ht+1,:);&lt;br /&gt;
figure(2)&lt;br /&gt;
subplot(2,2,1)&lt;br /&gt;
hold on&lt;br /&gt;
plot(X,t0)&lt;br /&gt;
plot(X,V(1,:),'r')&lt;br /&gt;
xlabel('x')&lt;br /&gt;
ylabel('temperature with t=0')&lt;br /&gt;
hold off&lt;br /&gt;
subplot(2,2,2)&lt;br /&gt;
hold on&lt;br /&gt;
plot(X,t1)&lt;br /&gt;
plot(X,V(1+1/ht,:),'r')&lt;br /&gt;
xlabel('x')&lt;br /&gt;
ylabel('temperature with t=1')&lt;br /&gt;
hold off&lt;br /&gt;
subplot(2,2,3)&lt;br /&gt;
hold on&lt;br /&gt;
plot(X,t2)&lt;br /&gt;
plot(X,V(1+2/ht,:),'r')&lt;br /&gt;
xlabel('x')&lt;br /&gt;
ylabel('temperature with t=2')&lt;br /&gt;
hold off&lt;br /&gt;
subplot(2,2,4)&lt;br /&gt;
hold on&lt;br /&gt;
plot(X,t10)&lt;br /&gt;
plot(X,V(1+10/ht,:),'r')&lt;br /&gt;
xlabel('x')&lt;br /&gt;
ylabel('temperature with t=10')&lt;br /&gt;
hold off&lt;br /&gt;
figure(3)&lt;br /&gt;
subplot(2,2,1)&lt;br /&gt;
e1=abs(t0-V(1,:));me1=max(e1);...&lt;br /&gt;
sprintf('The maximum difference with the stationary solution in t=0 is %d .',me1)&lt;br /&gt;
plot(X,e1,'g'),xlabel('x'),...&lt;br /&gt;
ylabel('Difference with the stationary solution in t=0') &lt;br /&gt;
subplot(2,2,2)&lt;br /&gt;
e2=abs(t1-V(1+1/ht,:));me2=max(e2);...&lt;br /&gt;
sprintf('The maximum difference with the stationary solution in t=1 is %d .',me2)&lt;br /&gt;
plot(X,e2,'g'),xlabel('x'),...&lt;br /&gt;
ylabel('Difference with the stationary solution t=1') &lt;br /&gt;
subplot(2,2,3)&lt;br /&gt;
e3=abs(t2-V(1+2/ht,:));me3=max(e3);...&lt;br /&gt;
sprintf('The maximum difference with the stationary solution in t=2 is %d .',me3)&lt;br /&gt;
plot(X,e3,'g'),xlabel('x'),...&lt;br /&gt;
ylabel('Difference with the stationary solution in t=2') &lt;br /&gt;
subplot(2,2,4)&lt;br /&gt;
e4=abs(t10-V(1+10/ht,:));me4=max(e4);...&lt;br /&gt;
sprintf('The maximum difference with the stationary solution in t=10 is %d .',me4)&lt;br /&gt;
plot(X,e4,'g'),xlabel('x'),ylabel('Difference with the stationary solution in t=10') &lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: untitled7.jpg|thumb|750px|left|Real surfaces and the stationary solution (in pink)]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This second graph shows as as we move in time (t older) solving our heat equation (blue) is more assimilated to the (red) stationary solution.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: untitled5.jpg|thumb|750px|left|Comparing solutions in &amp;lt;math&amp;gt;t=0,1,2,10&amp;lt;/math&amp;gt;]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
We now show the difference between the previous two solutions stationary real and represented throughout the rod for different values of time. We see how to increasingly large time difference between the two is narrowing, observing the order of magnitude in the ordinate.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: untitled6.jpg|thumb|750px|left|Differences with the stationary solution &amp;lt;math&amp;gt;t=0,1,2,10&amp;lt;/math&amp;gt; order]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Neumann type boundary condition=&lt;br /&gt;
&lt;br /&gt;
Now let's consider a different boundary condition at the right end. Instead of assuming a constant temperature at that end as above, we will place on it an insulating piece. This isolate causes no loss of heat at the right end, that is, the flow temperature is null. This condition is of Neumann type, unlike the previous ones were Dirichlet. So, we keep the condition at the left end and apply the new on the far right, which is&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;-ku_x(3,t)=0 \rightarrow &amp;lt;/math&amp;gt; $\boxed{u_x(3,t)=0}$&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this situation, the temperature of the rod is given by the following problem&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{cases}&lt;br /&gt;
u_t-u_{xx}=0, \qquad x\epsilon(0,3), t&amp;gt;0\\&lt;br /&gt;
u(0,t)=0, u_x(3,t)=0, \qquad t&amp;gt;0\\&lt;br /&gt;
u(x,0)=u_0(x), \qquad x\epsilon[0,3]&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So far in the stationary state for large times the &amp;lt;math&amp;gt; function u (x, t) &amp;lt;/math&amp;gt; that models the temperature of the rod is solution of the following boundary value problem (we call it that because the differential equation depends only &amp;lt;math&amp;gt; x &amp;lt;/math&amp;gt; in the stationary state)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{cases}&lt;br /&gt;
u_{xx}=0, \qquad x\epsilon(0,3), t&amp;gt;0\\&lt;br /&gt;
u(0,t)=0, u_x(3,t)=0, \qquad t&amp;gt;0&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We solve the differential equation to obtain the same result as above&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;u_{xx}=0 \rightarrow u(x,t)=C_1(t)x+C_2(t)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Applying the boundary conditions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;C_1(t)=C_2(t)=0 \rightarrow &amp;lt;/math&amp;gt; $\boxed{u(x,t)=0}$&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This result shows that after a large enough time to consider a steady state in the rod, it acquires a uniform zero temperature. The behavior of the rod is consistent with the boundary conditions, as its final temperature matches that remains constant in the far left.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Finite difference method==&lt;br /&gt;
&lt;br /&gt;
The following image shows an approximation of the problem is shown by the method of finite differences. It can be seen as a high value of the temperature in the rod can be considered constant and uniform throughout, reaching the stationary value &amp;lt;math&amp;gt; u (x, t) = 0 &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo:AP6a.png|thumb|750px|left|Solution of the problem with Neumann type boundary condition]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Specifically, from a time  &amp;lt;math&amp;gt; t = 26.4&amp;lt;/math&amp;gt; we can consider that the temperature reaches stationary value with an error of 0.05, that is, at that moment the difference between the calculated and the thermal distribution stationary takes that value.&lt;br /&gt;
&lt;br /&gt;
Below is reflected Matlab code which approximates the temperature of the rod by using the finite difference method as the implicit Euler that provides a better approximation with a step size  &amp;lt;math&amp;gt; h = 0.1 &amp;lt;/math&amp;gt; in time and space, and &amp;lt;math&amp;gt;t \in \mbox{[0,30]}&amp;lt;/math&amp;gt;. Furthermore, in the instant code approximation value differs 0.05 steady in all parts of the rod is calculated.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
clear all&lt;br /&gt;
%Sixth paragraph of labor&lt;br /&gt;
%solve the heat equation ut-uxx = 0 with&lt;br /&gt;
% U (0, t) = 0 ux (L, t) = 0 u (x, 0) = the function piecewise title&lt;br /&gt;
L=3;T=30;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=2*hx;&lt;br /&gt;
K=(2*diag(ones(1,Nx))-diag(ones(1,Nx-1),1)-diag(ones(1,Nx-1),-1));&lt;br /&gt;
K(Nx,Nx-1)=-2;K=K/(hx^2);&lt;br /&gt;
x=hx:hx:L;&lt;br /&gt;
F=zeros(Nx,1);&lt;br /&gt;
t=0:ht:T;&lt;br /&gt;
u0=10*x/3;u0(10:20)=100;&lt;br /&gt;
uu=u0';&lt;br /&gt;
U(1,:)=[0 u0];&lt;br /&gt;
%metoodo de Euler implicito&lt;br /&gt;
for n=1:(length(t)-1)&lt;br /&gt;
 uu=(eye(Nx)+(ht)*K)\(uu+ht*F);&lt;br /&gt;
 U(n+1,:)=[0 uu'];&lt;br /&gt;
end&lt;br /&gt;
p=0.05*ones(1,length(x)+1);&lt;br /&gt;
for i=1:length(t)&lt;br /&gt;
if min(U(i,:)&amp;lt;=p)==1 &lt;br /&gt;
    break &lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
SOL=t(i)&lt;br /&gt;
X=0:hx:L;&lt;br /&gt;
[xx,tt]=meshgrid(X,t);&lt;br /&gt;
surf(xx,tt,U)&lt;br /&gt;
title('Solution of the problem with Neumann type boundary condition')&lt;br /&gt;
xlabel('Space')&lt;br /&gt;
ylabel('Time')&lt;br /&gt;
zlabel('Temperature')&lt;br /&gt;
p=U(:,Nx+1);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Fourier Method==&lt;br /&gt;
&lt;br /&gt;
We propose now the same problem using the Fourier method. Thus, we seek solutions &amp;lt;math&amp;gt; u (x, t) = \ varphi (x) T (t) &amp;lt;/math&amp;gt; form, where &amp;lt;math&amp;gt; \ varphi (x) &amp;lt;/math&amp;gt; must satisfy the following problem eigenvalue&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{cases}&lt;br /&gt;
\varphi’’(x)+\lambda\varphi(x)=0\\&lt;br /&gt;
\varphi(0)=0, \varphi’(3)=0&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The solution of the differential equation is &amp;lt;math&amp;gt;\varphi(x)=a\cos(\sqrt{\lambda}x)+b\sin(\sqrt{\lambda}x)&amp;lt;/math&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Applying the boundary conditions we obtain the eigenvalues &amp;lt;math&amp;gt;\mu_k&amp;lt;/math&amp;gt; and eigenfunctions &amp;lt;math&amp;gt;\varphi_k(x)&amp;lt;/math&amp;gt; of the problem&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\varphi(0)=0 \rightarrow a=0&amp;lt;/math&amp;gt;;&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\varphi’(3)=0 \rightarrow \sqrt{\lambda}\,b\cos(\sqrt{\lambda}\,3)=0 \rightarrow \sqrt{\lambda}\,3=(k-{1\over2})\,\pi \rightarrow &amp;lt;/math&amp;gt; $\boxed{\lambda=\mu_k=(k-{1\over2})^2{\pi^2\over9}}$;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;Así $\boxed{\varphi_k(x)=\sin(k-{1\over2}){\pi\over3}x}$, &amp;lt;math&amp;gt; \qquad k=1,2,3…N&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If we apply that &amp;lt;math&amp;gt; u_k (x, t) = \ varphi_k (x) T_k (t) &amp;lt;/ math&amp;gt; satisfies the differential equation&amp;lt;math&amp;gt;  u_t-u {xx} = 0 &amp;lt;/ math&amp;gt;, we obtain the differential equation determines &amp;lt;math&amp;gt;T_k(t)&amp;lt;/math&amp;gt;&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;u_t-u{xx}=0 \rightarrow \varphi_k(x)T_k’(t)-\varphi_k’’(x)T_k(t)=\varphi_k(x)T_k’(t)-(-\mu_k)\varphi_k(x)T_k(t)=0 \rightarrow &amp;lt;/math&amp;gt; $\boxed{T_k’(t)+\mu_kT_k(t)=0}$&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solution of this differential equation $\boxed{T_k(t)=C_ke^{-\mu_kt}= C_ke^{-(k-{1\over2})^2{\pi^2\over9}t}}$ and therefore &amp;lt;math&amp;gt;u_k(x,t)= \varphi_k(x)T_k(t)=C_ke^{-(k-{1\over2})^2{\pi^2\over9}t}\sin(k-{1\over2}){\pi\over3}x&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If we express the solution of the problem as $ \ boxed {u (x, t) = \sum_ {k = 1} ^ Nu_k (x, t) = \sum_ {k = 1} ^ N ^ C_ke {- (k-{1 \over2}) ^ 2 {\pi ^ 2 \over9} t} \sin (k-{1 \over2}) {\pi \over3} x} $ and make satisfying the initial condition we obtain &amp;lt;math&amp;gt;u(x,0)=\sum_{k=1}^NC_k\sin(k-{1\over2}){\pi\over3}x&amp;lt;/math&amp;gt;. Thus, by uniqueness of the Fourier coefficients, the coefficients &amp;lt;math&amp;gt; C_K &amp;lt;/math&amp;gt; match those of the Fourier series with respect to the eigenfunctions &amp;lt;math&amp;gt; \varphi_k (x) &amp;lt;/math&amp;gt; Function apart that determines the initial condition (expressed at the beginning of the article).&lt;br /&gt;
&lt;br /&gt;
The problem is thus limited to the calculation of these coefficients according to the expression&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;$\boxed{C_k={\int_{0}^{3}u(x,0)\varphi_k(x)dx\over\int_{0}^{3}\varphi_k^2(x)dx}}$&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The degree of accuracy of the approximation with this method depends on the number of elements in the Fourier series, ie, the value of &amp;lt;math&amp;gt; N &amp;lt;/math&amp;gt;. We study the temperature of the rod taking &amp;lt;math&amp;gt;  N = 1,3,5,10,20 &amp;lt;/math&amp;gt; values, as you can see in the picture below. It can be seen, especially in the initial condition, that as the value of &amp;lt;math&amp;gt; N &amp;lt;/math&amp;gt; is the approximate increase function is closer to the real.&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo:Untitled4.jpg|thumb|750px|left|Solutions with different number of terms of the Fourier series]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
These results can be better taking a compare &amp;lt;math&amp;gt;  t = 0.5 &amp;lt;/math&amp;gt; fixed instant, and representing each function it in the same graph, as we see below. For this case we also added the approximation with 2 terms of the Fourier series to reflect that up to 3 terms approaches can be distinguished, but once this number of elements in the series approximations are virtually indistinguishable when compared on the same graph.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[Archivo:Untitled3.jpg|thumb|750px|left|Graph of temperature in t=0.5 with N terms of the Fourier series]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The following Matlab code which approximates the temperature of the rod by the Fourier method, with N = 1,3,5,10,20 terms of the series, and step size is reflected&amp;lt;math&amp;gt;h=0,1&amp;lt;/math&amp;gt; in time and space, and &amp;lt;math&amp;gt;t \in \mbox{[0,10]}&amp;lt;/math&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
clear all&lt;br /&gt;
%Seventh section of the paper&lt;br /&gt;
% solve the heat equation ut-uxx = 0 with&lt;br /&gt;
% U (0, t) = 0 ux (L, t) = 0 u (x, 0) = the function piecewise title&lt;br /&gt;
% Resolution with fourier&lt;br /&gt;
L=3;T=10;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=hx;&lt;br /&gt;
x=0:hx:L;t=0:ht:T;&lt;br /&gt;
[xx,tt]=meshgrid(x,t);&lt;br /&gt;
q=[1,2,3,5,10,20];&lt;br /&gt;
a=[1,3,5,10,20];&lt;br /&gt;
f=10*x/3;f(11:21)=100;&lt;br /&gt;
i=0;&lt;br /&gt;
for Q=q&lt;br /&gt;
u=0;&lt;br /&gt;
for k=1:Q&lt;br /&gt;
    p=sin((k-1/2)*(pi/3)*x);&lt;br /&gt;
    c=trapz(x,f.*p)/trapz(x,p.*p);&lt;br /&gt;
    u=u+c*exp(-((k-1/2)^2)*((pi/3)^2)*tt).*sin((k-1/2)*(pi/3)*xx);&lt;br /&gt;
end&lt;br /&gt;
b=find(Q==a);&lt;br /&gt;
if b&amp;lt;6&lt;br /&gt;
i=i+1;&lt;br /&gt;
figure(1)&lt;br /&gt;
subplot(2,3,i)&lt;br /&gt;
ca=num2str(Q);r=strcat(['Solution with ',ca,' terms of the Fourier series']);&lt;br /&gt;
if Q==1&lt;br /&gt;
r=strcat(['Solution with ',ca,' term of the Fourier series']);&lt;br /&gt;
end&lt;br /&gt;
surf(xx,tt,u),xlabel('Space'),ylabel('Time'),zlabel('Temperature'),title(r)&lt;br /&gt;
end&lt;br /&gt;
d(find(q==Q),:)=u(0.5/ht+1,:);&lt;br /&gt;
end&lt;br /&gt;
figure(2)&lt;br /&gt;
hold on&lt;br /&gt;
title('Temperature in t=0.5 with N terms of the Fourier series')&lt;br /&gt;
plot(x,d(1:6,:))&lt;br /&gt;
xlabel('Space'),ylabel('Time')&lt;br /&gt;
legend('N=1','N=2','N=3','N=5','N=10','N=20','Location','best')&lt;br /&gt;
hold off&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Losses along the rod=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now we will study the case where there are heat sources or sinks along the rod. Specifically, if there is heat loss through the air having a constant temperature of 16 degrees. With the boundary conditions that we had initially keeping the left and right at 0 and 10 degrees respectively ends, the problem would be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{cases}&lt;br /&gt;
u_t-u_{xx}+u-16=0,\ x \in \mbox{[0,3]} &amp;amp;  t&amp;gt;0 \\&lt;br /&gt;
u(0,t)=0; u(3,t)=10; &amp;amp; u(x,0)=g(x) ;&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;math&amp;gt;g(x)&amp;lt;/math&amp;gt;  is defined as in the first problem:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
u_0=&lt;br /&gt;
\begin{cases}&lt;br /&gt;
10x/3 &amp;amp;  \mbox{si}  &amp;amp;  x \in \mbox{(0,1)} \cup \mbox{(2,3)}   \\&lt;br /&gt;
100     &amp;amp;  \mbox{si}  &amp;amp;   x \in \mbox{(1,2)}   &lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To solve the problem by finite differences with a term in &amp;lt;math&amp;gt; u (x, t) &amp;lt;/math&amp;gt; need to rethink the discretization in space:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{cases}&lt;br /&gt;
u’_n(t)+\frac{-u_{n-1}(t)+2u_n(t)-u_{n+1}(t)}{h^2}+u_n(t)=16&amp;amp;n=1,2,…,N&amp;amp;t&amp;gt;0 \\&lt;br /&gt;
u_0(t)=0 \\&lt;br /&gt;
u_N(t)=10 \\&lt;br /&gt;
u_n(0)=g(x)&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus, the resulting matrices are as follows&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
K=&lt;br /&gt;
\begin{pmatrix}&lt;br /&gt;
 2 &amp;amp; -1 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp; 0 &amp;amp; 0 \\&lt;br /&gt;
 -1 &amp;amp; 2 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp;0 &amp;amp; 0 \\&lt;br /&gt;
 … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … \\&lt;br /&gt;
 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp; -1 &amp;amp; 2 &lt;br /&gt;
\end{pmatrix}&lt;br /&gt;
\frac{1}{h^2}+&lt;br /&gt;
\begin{pmatrix} &lt;br /&gt;
1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp; 0 &amp;amp; 0 \\&lt;br /&gt;
0 &amp;amp; 1 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp;0 &amp;amp; 0 \\&lt;br /&gt;
… &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … \\&lt;br /&gt;
0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp; 0 &amp;amp; 1&lt;br /&gt;
\end{pmatrix}&lt;br /&gt;
&amp;lt;/math&amp;gt;; &amp;lt;math&amp;gt;&lt;br /&gt;
F=&lt;br /&gt;
\begin{pmatrix}&lt;br /&gt;
16+\frac{0}{h^2} \\&lt;br /&gt;
16 \\&lt;br /&gt;
… \\&lt;br /&gt;
16+\frac{10}{h^2} \\&lt;br /&gt;
\end{pmatrix}&lt;br /&gt;
&amp;lt;/math&amp;gt;; &amp;lt;math&amp;gt;&lt;br /&gt;
U=&lt;br /&gt;
\begin{pmatrix}&lt;br /&gt;
u_1 \\&lt;br /&gt;
u_2 \\&lt;br /&gt;
… \\&lt;br /&gt;
u_{N-1} \\&lt;br /&gt;
\end{pmatrix}&lt;br /&gt;
&amp;lt;/math&amp;gt;; &amp;lt;math&amp;gt;&lt;br /&gt;
U^0=&lt;br /&gt;
\begin{pmatrix}&lt;br /&gt;
g(x_1) \\&lt;br /&gt;
g(x_2) \\&lt;br /&gt;
… \\&lt;br /&gt;
g(x_{N-1})&lt;br /&gt;
\end{pmatrix}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this we can move to numerically solve the problem, but we must recalculate the steady state of the despising rod &amp;lt;math&amp;gt;u_t(x,t)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;u_t(x,t)\approx 0; \ u_{xx}-u+16=0; \ u(0)=0 \ u(3)=10&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is nothing more than an ordinary differential equation of 2nd order with constant coefficients, whose solution is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;a(t)e^x+b(t)e^{-x}+16&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;math&amp;gt; a (t) &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; b (t) &amp;lt;/math&amp;gt; are constants to be obtained to replace and solve the system with the boundary conditions, which in our case have let him Matlab resolved (see lines 22 and 23 of the code).&lt;br /&gt;
Now, we turn to numerically solve the problem, with &amp;lt;math&amp;gt;h=0,1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;t \in \mbox{[0,10]}&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
clear all&lt;br /&gt;
%solve the heat equation ut-uxx + u-16 = 0 with&lt;br /&gt;
% U (0, t) = 0 u (l, t) = 10 u (x, 0) = the function to set pieces&lt;br /&gt;
L=3;T=10;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=hx;&lt;br /&gt;
K=(2*diag(ones(1,Nx-1))-diag(ones(1,Nx-2),1)-diag(ones(1,Nx-2),-1))/(hx^2);&lt;br /&gt;
K=K+eye(Nx-1);&lt;br /&gt;
x=hx:hx:L-hx;&lt;br /&gt;
F=16*ones(Nx-1,1);F(Nx-1)=16+10/(hx^2);&lt;br /&gt;
t=0:ht:T;&lt;br /&gt;
u0=10*x/3;u0(10:20)=100;&lt;br /&gt;
uu=u0';&lt;br /&gt;
U(1,:)=[0 u0 10];&lt;br /&gt;
%metoodo de Euler implicito&lt;br /&gt;
for n=1:(length(t)-1)&lt;br /&gt;
 uu=(eye(Nx-1)+(ht)*K)\(uu+ht*F);&lt;br /&gt;
 U(n+1,:)=[0 uu' 10];&lt;br /&gt;
end&lt;br /&gt;
X=0:hx:L;&lt;br /&gt;
[xx,tt]=meshgrid(X,t);&lt;br /&gt;
a=[1 1;exp(3) exp(-3)];b=[-16;-6];d=a\b;&lt;br /&gt;
V=d(1)*exp(xx)+d(2)*exp(-xx)+16*ones(T/ht+1,Nx+1);&lt;br /&gt;
figure(1)&lt;br /&gt;
hold on&lt;br /&gt;
surf(xx,tt,U)&lt;br /&gt;
xlabel('space')&lt;br /&gt;
ylabel('time')&lt;br /&gt;
zlabel('temperature')&lt;br /&gt;
h1=surf(xx,tt,V),set(h1,'FaceColor','red','FaceAlpha',0.5,'EdgeColor','w')&lt;br /&gt;
xlabel('space')&lt;br /&gt;
ylabel('time')&lt;br /&gt;
zlabel('temperature')&lt;br /&gt;
E=abs(U-V);&lt;br /&gt;
e1=E(46:101,Nx/6+1);&lt;br /&gt;
e2=E(46:101,Nx/3+1);&lt;br /&gt;
e3=E(46:101,Nx/2+1);&lt;br /&gt;
e4=E(46:101,2*Nx/3+1);&lt;br /&gt;
e5=E(46:101,5*Nx/6+1);&lt;br /&gt;
figure(3)&lt;br /&gt;
hold on&lt;br /&gt;
plot(t(46:101),e1)&lt;br /&gt;
plot(t(46:101),e2,'r')&lt;br /&gt;
plot(t(46:101),e3,'k')&lt;br /&gt;
plot(t(46:101),e4,'m')&lt;br /&gt;
plot(t(46:101),e5,'c'),legend('Difference in x=0.5','Difference in x=1',...&lt;br /&gt;
'Difference in x=1.5','Difference in x=2','Difference in x=2.5')&lt;br /&gt;
plot(t(46:101),0.001*ones(1,length(t)-45),'g'),xlabel('time'),...&lt;br /&gt;
ylabel('Difference with the stationary solution')&lt;br /&gt;
hold off&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo:Untitled002.jpg|thumb|750px|left|Graph of &amp;lt;math&amp;gt;u(x,t)&amp;lt;/math&amp;gt;  in &amp;lt;math&amp;gt;x \in \mbox{[0,3]};t \in \mbox{[0,10]}&amp;lt;/math&amp;gt;. In pink is the stationary solution. ]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
As shown in the graph, the actual solution and stationary are virtually identical for &amp;lt;math&amp;gt;  t&amp;gt; 2 &amp;lt;/math&amp;gt;. Furthermore we see that near &amp;lt;math&amp;gt; t = 5 &amp;lt;/math&amp;gt; the stationary solution is above the real solution. This is best seen in the following graph in which are represented the difference between the actual solution and the stationary for different values of &amp;lt;math&amp;gt;  x &amp;lt;/math&amp;gt;, namely &amp;lt;math&amp;gt;x = 0.5,1,1.5,2,2.5  &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo:Untitled01.jpg|thumb|750px|left|Graph with the difference between the real and the stationary solution for&amp;lt;math&amp;gt;t \in \mbox{[4.5,10]}&amp;lt;/math&amp;gt; ]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
At that point cut the difference between the two is minimal, below &amp;lt;math&amp;gt; 10 ^ {-3 } &amp;lt;/math&amp;gt;, while from there this difference increases slightly and remained constant when time is increasing. This was expected, since for large times the solution of the equation is stationary, and therefore effects of time we have is the difference between two constants. The existing small difference between the two may be because logically, does not disclose exact thing but we are solving the equation numerically.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Changing the boundary conditions==&lt;br /&gt;
&lt;br /&gt;
Suppose now that we change the boundary conditions, so that now the left end of the rod to be in contact with a material whose temperature varies according to the function &amp;lt;math&amp;gt; 10sen (t) &amp;lt;/math&amp;gt;, and by the end right there is a flow of constant heat input &amp;lt;math&amp;gt; 1 &amp;lt;/math&amp;gt;. These conditions translate as &amp;lt;math&amp;gt; u (0, t) = 10sen (t) &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; u_x (3, t) = 1 &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
As the second condition of Neumann type, size of the matrices increases one unit, to be known &amp;lt;math&amp;gt; u_n &amp;lt;/math&amp;gt; term. Also &amp;lt;math&amp;gt; K &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; F &amp;lt;/math&amp;gt; change their terms, becoming&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
K=&lt;br /&gt;
\begin{pmatrix}&lt;br /&gt;
 2 &amp;amp; -1 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp; 0 &amp;amp; 0 \\&lt;br /&gt;
 -1 &amp;amp; 2 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp;0 &amp;amp; 0 \\&lt;br /&gt;
 … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … \\&lt;br /&gt;
 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp; -2 &amp;amp; 2 &lt;br /&gt;
\end{pmatrix}&lt;br /&gt;
\frac{1}{h^2}+&lt;br /&gt;
\begin{pmatrix} &lt;br /&gt;
1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp; 0 &amp;amp; 0 \\&lt;br /&gt;
0 &amp;amp; 1 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp;0 &amp;amp; 0 \\&lt;br /&gt;
… &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … \\&lt;br /&gt;
0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp; 0 &amp;amp; 1&lt;br /&gt;
\end{pmatrix}&lt;br /&gt;
&amp;lt;/math&amp;gt;; &amp;lt;math&amp;gt;&lt;br /&gt;
F=&lt;br /&gt;
\begin{pmatrix}&lt;br /&gt;
16+\frac{10sen(t_n)}{h^2} \\&lt;br /&gt;
16 \\&lt;br /&gt;
… \\&lt;br /&gt;
16+\frac{2}{h} \\&lt;br /&gt;
\end{pmatrix}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We solve the implicit Euler method with &amp;lt;math&amp;gt;h=0,1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;t \in \mbox{[0,10]}&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
clear all&lt;br /&gt;
%solve the heat equation ut-uxx + u-16 = 0 with&lt;br /&gt;
% U (0, t) = 10 * sin (t) ux (L, t) = 1 u (x, 0) = the function piecewise title&lt;br /&gt;
L=3;T=10;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=hx;&lt;br /&gt;
K=(2*diag(ones(1,Nx))-diag(ones(1,Nx-1),1)-diag(ones(1,Nx-1),-1));K(Nx,Nx-1)=-2;K=K/(hx^2);&lt;br /&gt;
K=K+eye(Nx);&lt;br /&gt;
x=hx:hx:L;&lt;br /&gt;
t=0:ht:T;&lt;br /&gt;
u0=10*x/3;u0(10:20)=100;&lt;br /&gt;
uu=u0';&lt;br /&gt;
g=10*sin(t);&lt;br /&gt;
U(1,:)=[g(1) u0];&lt;br /&gt;
%implicit Euler method&lt;br /&gt;
for n=1:(length(t)-1)&lt;br /&gt;
   F=16*ones(Nx,1);F(Nx)=16+2/hx;F(1)=16+g(n)/(hx^2);&lt;br /&gt;
   uu=(eye(Nx)+(ht)*K)\(uu+ht*F);&lt;br /&gt;
   U(n+1,:)=[g(n+1) uu'];&lt;br /&gt;
end&lt;br /&gt;
X=0:hx:L;&lt;br /&gt;
[xx,tt]=meshgrid(X,t);&lt;br /&gt;
figure(1)&lt;br /&gt;
surf(xx,tt,U)&lt;br /&gt;
xlabel('space')&lt;br /&gt;
ylabel('time')&lt;br /&gt;
zlabel('Temperature')&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo:untitled.jpg|thumb|750px|left|Graph of &amp;lt;math&amp;gt;u(x,t)&amp;lt;/math&amp;gt;  in &amp;lt;math&amp;gt;x \in \mbox{[0,3]};t \in \mbox{[0,10]}&amp;lt;/math&amp;gt; ]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In view of the graph we can conclude that as previously when we had a Neumann type condition, the heat &amp;quot;escapes&amp;quot; from the left end at a variable temperature with time while entering from the right. This can be seen if the program is run on the graph by observing the slight slope that the surface of temperatures has at the left side.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Categoría:Ecuaciones Diferenciales]]&lt;br /&gt;
[[Categoría:ED13/14]]&lt;br /&gt;
[[Categoría:Trabajos 2013-14]]&lt;/div&gt;</summary>
		<author><name>Marino Rivera</name></author>	</entry>

	<entry>
		<id>https://mat.caminos.upm.es/w/index.php?title=Heat_equation_(Grupo_1B)&amp;diff=12231</id>
		<title>Heat equation (Grupo 1B)</title>
		<link rel="alternate" type="text/html" href="https://mat.caminos.upm.es/w/index.php?title=Heat_equation_(Grupo_1B)&amp;diff=12231"/>
				<updated>2014-05-18T17:11:07Z</updated>
		
		<summary type="html">&lt;p&gt;Marino Rivera: Marino Rivera movió la página Heat equation a Heat equation (Grupo 1B)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ TrabajoED |Heat equation. Grupo 1-B | [[:Categoría:Ecuaciones Diferenciales|Ecuaciones Diferenciales]]|[[:Categoría:ED13/14|Curso 2013-14]] | Sandro Andrés Martínez &lt;br /&gt;
 &lt;br /&gt;
David Ayala Díez &lt;br /&gt;
 &lt;br /&gt;
Claudia Cózar Coarasa  &lt;br /&gt;
&lt;br /&gt;
Lorena de la Fuente Sanz  &lt;br /&gt;
&lt;br /&gt;
Marino Rivera Muñoz &lt;br /&gt;
  &lt;br /&gt;
José Manuel Torres Serrano }}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this work we have studied the modeling of the heat equation, according to Fourier's law discovered in the nineteenth century.&lt;br /&gt;
&lt;br /&gt;
= Well proposed problem  =&lt;br /&gt;
&lt;br /&gt;
[[Archivo:Nueva imagen.png|thumb|300px|left| Thin rod of length L]]&lt;br /&gt;
&lt;br /&gt;
We will raise the system of equations that satisfies &amp;lt;math&amp;gt;u(x,t)&amp;lt;/math&amp;gt; assuming that the temperature of the rod &amp;lt;math&amp;gt;u(x,t)&amp;lt;/math&amp;gt; satisfies the heat equation &amp;lt;math&amp;gt;u_t-u_{xx}=0&amp;lt;/math&amp;gt;. First, we have a thin, homogeneous and thermally isolated by its lateral surface rod of length  &amp;lt;math&amp;gt;L=3&amp;lt;/math&amp;gt;. At its left end the rod is in contact with a material whose temperature is maintained at 0°C, while the right is in contact with the material at 10°C. We also know that at the initial moment, the temperature distribution follows the &amp;lt;math&amp;gt;u(x,0)=u_0(x)&amp;lt;/math&amp;gt; function specified below. Assuming a standard &amp;lt;math&amp;gt;c=\rho=k=1&amp;lt;/math&amp;gt; parameters and there are no heat sources or sinks along the rod, the problem we have to solve is:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;math&amp;gt;&lt;br /&gt;
(P)&lt;br /&gt;
\begin{cases}&lt;br /&gt;
u_t-u_{xx}=0, \qquad x\epsilon(0,3), t&amp;gt;0\\&lt;br /&gt;
u(0,t)=0, u(3,t)=10, \qquad t&amp;gt;0\\&lt;br /&gt;
u(x,0)=u_0(x), \qquad x\epsilon[0,3]&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
:&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
u_0(x)=&lt;br /&gt;
\begin{cases}&lt;br /&gt;
10x/3 &amp;amp;  \mbox{si}  &amp;amp;  x \in \mbox{(0,1)}\cup\mbox{(2,3)}   \\&lt;br /&gt;
100     &amp;amp;  \mbox{si}  &amp;amp;   x \in \mbox{(1,2)}   &lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Then we will define what is a well proposed problem is one that meets the following:&lt;br /&gt;
&lt;br /&gt;
•	Existence: problem &amp;lt;math&amp;gt;(P)&amp;lt;/math&amp;gt; admits a solution &amp;lt;math&amp;gt;u(x,t)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
•	Uniqueness: if there is a solution &amp;lt;math&amp;gt;(P)&amp;lt;/math&amp;gt; it has to be unique.&lt;br /&gt;
&lt;br /&gt;
•	Stability with respect to initial data: &lt;br /&gt;
We consider the problem:&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
(P_1)&lt;br /&gt;
\begin{cases}&lt;br /&gt;
u_t-u_{xx}=0, \qquad x\epsilon(0,3), t&amp;gt;0\\&lt;br /&gt;
u(0,t)=0, u(3,t)=10, \qquad t&amp;gt;0\\&lt;br /&gt;
u(x,0)=h(x), \qquad x\epsilon[0,3]&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Be &amp;lt;math&amp;gt;u(x,t)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;u_1(x,t)&amp;lt;/math&amp;gt; &amp;lt;math&amp;gt;(P)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;(P_1)&amp;lt;/math&amp;gt; solutions respectively. We say that the &amp;lt;math&amp;gt;(P)&amp;lt;/math&amp;gt; problem is stable with respect to initial data if we prove the inequality of type &amp;lt;math&amp;gt;sup_{(x,t)\in [0,3]x[0,\infty]}\left|u(x,t)-u_1(x,t)\right|\leq Csup_{(x,t)\in [0,3]x[0,\infty]}\left|u_0(x)-h(x)\right|&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; absolute, constant independent of the &amp;lt;math&amp;gt;(P)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;(P_1)&amp;lt;/math&amp;gt; problems.&lt;br /&gt;
&lt;br /&gt;
That &amp;lt;math&amp;gt; (P) &amp;lt;/math&amp;gt; is stable with respect to initial data tells us that if &amp;lt;math&amp;gt; h (x) &amp;lt;/math&amp;gt; is close to &amp;lt;math&amp;gt; u_0 (x) &amp;lt;/math&amp;gt; in the sense that &amp;lt;math&amp;gt; sup_ {(x, t) \ in [0,3] x [0, \infty]} \left | u_0 (x)-h (x) \right | &amp;lt;/math&amp;gt; is small, then the &amp;lt;math&amp;gt;  u (x, t) &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; u_1 (x, t) &amp;lt;/math&amp;gt; solutions are also nearby.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Resolution establishing finite difference method==&lt;br /&gt;
&lt;br /&gt;
Then the MATLAB code that numerically solves the heat equation posed exposed. It has been solved by the finite difference method with &amp;lt;math&amp;gt; \Delta x = 0.1 &amp;lt;/math&amp;gt; and we have used the method of taking time trapeze &amp;lt;math&amp;gt; \Delta t = \Delta x &amp;lt;/math&amp;gt;. The number of subintervals in which we divide the rod length is &amp;lt;math&amp;gt; Nx = 30 &amp;lt;/math&amp;gt; and time to which we have taken to represent &amp;lt;math&amp;gt; 2 &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
clear all&lt;br /&gt;
%solve the heat equation ut-uxx = 0 with&lt;br /&gt;
% u(0,t)=0 u(l,t)=10 u(x,0)=the piecewise title&lt;br /&gt;
L=3;T=2;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=hx;&lt;br /&gt;
K=(2*diag(ones(1,Nx-1))-diag(ones(1,Nx-2),1)-diag(ones(1,Nx-2),-1))/(hx^2);&lt;br /&gt;
x=hx:hx:L-hx;&lt;br /&gt;
F=zeros(Nx-1,1);F(Nx-1)=10/(hx^2);&lt;br /&gt;
t=0:ht:T;&lt;br /&gt;
u0=10*x/3;u0(10:20)=100;&lt;br /&gt;
uu=u0';&lt;br /&gt;
U(1,:)=[0 u0 10];&lt;br /&gt;
%method of trapezoids&lt;br /&gt;
for n=1:(length(t)-1)&lt;br /&gt;
 uu=(eye(Nx-1)+(ht/2)*K)\(uu+ht*(-K*uu+F+F)/2);&lt;br /&gt;
 U(n+1,:)=[0 uu' 10];&lt;br /&gt;
end&lt;br /&gt;
X=0:hx:L;&lt;br /&gt;
[xx,tt]=meshgrid(X,t);&lt;br /&gt;
m=U(:,16);&lt;br /&gt;
figure(1)&lt;br /&gt;
surf(xx,tt,U)&lt;br /&gt;
xlabel('space')&lt;br /&gt;
ylabel('time')&lt;br /&gt;
zlabel('temperature')&lt;br /&gt;
figure(2)&lt;br /&gt;
plot(t,m)&lt;br /&gt;
xlabel('time')&lt;br /&gt;
ylabel('temperature')&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
In this graph we have shown the 3D surface of the solution of the heat equation posed. As shown, although the trapezoidal method is an implicit method, not well approximated by the points of discontinuity of the initial condition and require less in the discretization step to remove these &amp;quot;peaks&amp;quot; that appear on the surface.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[Archivo: untitled11.jpg|thumb|750px|left|Solution of the heat equation]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the graph shown below the temperature behavior is shown in the middle of the rod with time. This is also obtained from the upper MATLAB code. Comparing the two graphs shows that the latter is a cut &amp;lt;math&amp;gt; x = 1.5 &amp;lt;/math&amp;gt; of the above.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[Archivo: gráfica3a.jpg|thumb|750px|left| u(t) ]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Resolution with different methods =&lt;br /&gt;
&lt;br /&gt;
We will solve the problem initially posed by the implicit and explicit methods by Euler and Runge-Kutta of order 4, following the same steps as with the method of the Trapezium.&lt;br /&gt;
&lt;br /&gt;
==Implicit Euler==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
&lt;br /&gt;
clear all&lt;br /&gt;
%solve the heat equation ut-uxx = 0 with&lt;br /&gt;
% u(0,t)=0 u(l,t)=10 u(x,0)=the piecewise title&lt;br /&gt;
L=3;T=2;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=hx;&lt;br /&gt;
K=(2*diag(ones(1,Nx-1))-diag(ones(1,Nx-2),1)-diag(ones(1,Nx-2),-1))/(hx^2);&lt;br /&gt;
x=hx:hx:L-hx;&lt;br /&gt;
F=zeros(Nx-1,1);F(Nx-1)=10/(hx^2);&lt;br /&gt;
t=0:ht:T;&lt;br /&gt;
u0=10*x/3;u0(10:20)=100;&lt;br /&gt;
uu=u0';&lt;br /&gt;
U(1,:)=[0 u0 10];&lt;br /&gt;
%implicit Euler method&lt;br /&gt;
for n=1:(length(t)-1)&lt;br /&gt;
 uu=(eye(Nx-1)+(ht)*K)\(uu+ht*F);&lt;br /&gt;
 U(n+1,:)=[0 uu' 10];&lt;br /&gt;
end&lt;br /&gt;
X=0:hx:L;&lt;br /&gt;
[xx,tt]=meshgrid(X,t);&lt;br /&gt;
m=U(:,16);&lt;br /&gt;
figure(1)&lt;br /&gt;
surf(xx,tt,U)&lt;br /&gt;
xlabel('space')&lt;br /&gt;
ylabel('time')&lt;br /&gt;
zlabel('temperature')&lt;br /&gt;
figure(2)&lt;br /&gt;
plot(t,m)&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: untitled00010.jpg|thumb|750px|left|Surface with the implicit Euler method]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: Grafica_Euler_impl%C3%ADcito.jpg |thumb|750px|left|&amp;lt;math&amp;gt; x = 1.5 &amp;lt;/math&amp;gt; Graph with the implicit Euler method]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Explicit Euler==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
&lt;br /&gt;
clear all&lt;br /&gt;
% Explicit Euler method&lt;br /&gt;
L=3;T=2;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=(hx^2)/2;% must do so, if not it does not work&lt;br /&gt;
K=(2*diag(ones(1,Nx-1))-diag(ones(1,Nx-2),1)-diag(ones(1,Nx-2),-1))/(hx^2);&lt;br /&gt;
x=hx:hx:L-hx;&lt;br /&gt;
F=zeros(Nx-1,1);F(Nx-1)=10/(hx^2);&lt;br /&gt;
t=0:ht:T;&lt;br /&gt;
u0=10*x/3;u0(10:20)=100;&lt;br /&gt;
uu=u0';&lt;br /&gt;
U(1,:)=[0 u0 10];&lt;br /&gt;
for n=1:(length(t)-1)&lt;br /&gt;
 uu=uu+ht*(-K*uu+F);&lt;br /&gt;
 U(n+1,:)=[0 uu' 10];&lt;br /&gt;
end&lt;br /&gt;
X=0:hx:L;&lt;br /&gt;
[xx,tt]=meshgrid(X,t);&lt;br /&gt;
m=U(:,16);&lt;br /&gt;
figure(3)&lt;br /&gt;
surf(xx,tt,U)&lt;br /&gt;
xlabel('space')&lt;br /&gt;
ylabel('time')&lt;br /&gt;
zlabel('Temperature')&lt;br /&gt;
figure(4)&lt;br /&gt;
plot(t,m)&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: untitled9.jpg|thumb|750px|left|Surface with explicit Euler method ]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: Euler1.3.jpg |thumb|750px|left|Graph in &amp;lt;math&amp;gt;x=1.5&amp;lt;/math&amp;gt; with explicit Euler method]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Runge-Kutta==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
&lt;br /&gt;
clear all&lt;br /&gt;
% Runge Kutta method&lt;br /&gt;
L=3;T=2;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=(hx^2)/2;% if we do not add ht it does not work&lt;br /&gt;
K=(2*diag(ones(1,Nx-1))-diag(ones(1,Nx-2),1)-diag(ones(1,Nx-2),-1))/(hx^2);&lt;br /&gt;
x=hx:hx:L-hx;&lt;br /&gt;
F=zeros(Nx-1,1);F(Nx-1)=10/(hx^2);&lt;br /&gt;
t=0:ht:T;&lt;br /&gt;
u0=10*x/3;u0(10:20)=100;&lt;br /&gt;
uu=u0';&lt;br /&gt;
U(1,:)=[0 u0 10];&lt;br /&gt;
for n=1:(length(t)-1)&lt;br /&gt;
 k1=-K*uu+F;&lt;br /&gt;
 k2=-K*(uu+k1*ht/2)+F;&lt;br /&gt;
 k3=-K*(uu+k2*ht/2)+F;&lt;br /&gt;
 k4=-K*(uu+k3*ht)+F;&lt;br /&gt;
 uu=uu+(ht/6)*(k1+2*k2+2*k3+k4);&lt;br /&gt;
 U(n+1,:)=[0 uu' 10];&lt;br /&gt;
end&lt;br /&gt;
X=0:hx:L;&lt;br /&gt;
[xx,tt]=meshgrid(X,t);&lt;br /&gt;
m=U(:,16);&lt;br /&gt;
figure(5)&lt;br /&gt;
surf(xx,tt,U)&lt;br /&gt;
xlabel('space')&lt;br /&gt;
ylabel('time')&lt;br /&gt;
zlabel('Temperature')&lt;br /&gt;
figure(6)&lt;br /&gt;
plot(t,m)&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: untitled8.jpg|thumb|750px|left|Surface with Runge Kutta method]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: Grafica_Runge_Kutta.jpeg|thumb|750px|left|Graph in &amp;lt;math&amp;gt;x=1.5&amp;lt;/math&amp;gt; Runge Kutta method]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can see that the method that works best is the implicit Euler, whereas explicit Euler and Runge-Kutta, being explicit methods require a rodent control into smaller intervals, and still not a good approximation is achieved as can be seen in the graph of the explicit Euler method. Therefore, for what follows, we use implicit Euler method.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Stationary state=&lt;br /&gt;
&lt;br /&gt;
It is said that a physical system is in stationary state when its characteristics do not vary with time. In this section we address this stationary state, which consists of neglecting the time and see what happens to our problem without taking into account the time variable.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;u_t(x,t)\approx 0; \ u_{xx}=0; \ u_x=c_1(t) \ u=c_1(t)x+c_2(t)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Substituting the boundary conditions:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;u(0)=0; \ c_2(t)=0; \ u(3)=10; \ c_1(t)=\frac{10}{3}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Thus the stationary solution is &amp;lt;math&amp;gt; u (x, t) = \ frac {10x} {3} &amp;lt;/math&amp;gt;, which is related to the initial condition. It seems logical that once the temperature in the center of the rod has dissipated, the ends having this constant temperature varies linearly between the two.&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
&lt;br /&gt;
clear all&lt;br /&gt;
%solve the heat equation ut-uxx = 0 with&lt;br /&gt;
% u(0,t)=0 u(l,t)=10 u(x,0)=the piecewise title&lt;br /&gt;
L=3;T=10;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=hx;&lt;br /&gt;
K=(2*diag(ones(1,Nx-1))-diag(ones(1,Nx-2),1)-diag(ones(1,Nx-2),-1))/(hx^2);&lt;br /&gt;
x=hx:hx:L-hx;&lt;br /&gt;
F=zeros(Nx-1,1);F(Nx-1)=10/(hx^2);&lt;br /&gt;
t=0:ht:T;&lt;br /&gt;
u0=10*x/3;u0(10:20)=100;&lt;br /&gt;
uu=u0';&lt;br /&gt;
U(1,:)=[0 u0 10];&lt;br /&gt;
%método de Euler implícito&lt;br /&gt;
for n=1:(length(t)-1)&lt;br /&gt;
 uu=(eye(Nx-1)+(ht)*K)\(uu+ht*F);&lt;br /&gt;
 U(n+1,:)=[0 uu' 10];&lt;br /&gt;
end&lt;br /&gt;
X=0:hx:L;&lt;br /&gt;
[xx,tt]=meshgrid(X,t);&lt;br /&gt;
%solución estacionaria u(x)=10/3*x&lt;br /&gt;
V=10*xx/3;&lt;br /&gt;
figure(1)&lt;br /&gt;
hold on&lt;br /&gt;
surf(xx,tt,U)&lt;br /&gt;
xlabel('space')&lt;br /&gt;
ylabel('time')&lt;br /&gt;
zlabel('Temperature')&lt;br /&gt;
h1=surf(xx,tt,V),set(h1,'FaceColor','magenta','FaceAlpha',0.5,'EdgeColor','w')&lt;br /&gt;
hold off&lt;br /&gt;
t0=U(1,:);t1=U(1/ht+1,:);t2=U(2/ht+1,:);t10=U(10/ht+1,:);&lt;br /&gt;
figure(2)&lt;br /&gt;
subplot(2,2,1)&lt;br /&gt;
hold on&lt;br /&gt;
plot(X,t0)&lt;br /&gt;
plot(X,V(1,:),'r')&lt;br /&gt;
xlabel('x')&lt;br /&gt;
ylabel('temperature with t=0')&lt;br /&gt;
hold off&lt;br /&gt;
subplot(2,2,2)&lt;br /&gt;
hold on&lt;br /&gt;
plot(X,t1)&lt;br /&gt;
plot(X,V(1+1/ht,:),'r')&lt;br /&gt;
xlabel('x')&lt;br /&gt;
ylabel('temperature with t=1')&lt;br /&gt;
hold off&lt;br /&gt;
subplot(2,2,3)&lt;br /&gt;
hold on&lt;br /&gt;
plot(X,t2)&lt;br /&gt;
plot(X,V(1+2/ht,:),'r')&lt;br /&gt;
xlabel('x')&lt;br /&gt;
ylabel('temperature with t=2')&lt;br /&gt;
hold off&lt;br /&gt;
subplot(2,2,4)&lt;br /&gt;
hold on&lt;br /&gt;
plot(X,t10)&lt;br /&gt;
plot(X,V(1+10/ht,:),'r')&lt;br /&gt;
xlabel('x')&lt;br /&gt;
ylabel('temperature with t=10')&lt;br /&gt;
hold off&lt;br /&gt;
figure(3)&lt;br /&gt;
subplot(2,2,1)&lt;br /&gt;
e1=abs(t0-V(1,:));me1=max(e1);...&lt;br /&gt;
sprintf('The maximum difference with the stationary solution in t=0 is %d .',me1)&lt;br /&gt;
plot(X,e1,'g'),xlabel('x'),...&lt;br /&gt;
ylabel('Difference with the stationary solution in t=0') &lt;br /&gt;
subplot(2,2,2)&lt;br /&gt;
e2=abs(t1-V(1+1/ht,:));me2=max(e2);...&lt;br /&gt;
sprintf('The maximum difference with the stationary solution in t=1 is %d .',me2)&lt;br /&gt;
plot(X,e2,'g'),xlabel('x'),...&lt;br /&gt;
ylabel('Difference with the stationary solution t=1') &lt;br /&gt;
subplot(2,2,3)&lt;br /&gt;
e3=abs(t2-V(1+2/ht,:));me3=max(e3);...&lt;br /&gt;
sprintf('The maximum difference with the stationary solution in t=2 is %d .',me3)&lt;br /&gt;
plot(X,e3,'g'),xlabel('x'),...&lt;br /&gt;
ylabel('Difference with the stationary solution in t=2') &lt;br /&gt;
subplot(2,2,4)&lt;br /&gt;
e4=abs(t10-V(1+10/ht,:));me4=max(e4);...&lt;br /&gt;
sprintf('The maximum difference with the stationary solution in t=10 is %d .',me4)&lt;br /&gt;
plot(X,e4,'g'),xlabel('x'),ylabel('Difference with the stationary solution in t=10') &lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: untitled7.jpg|thumb|750px|left|Real surfaces and the stationary solution (in pink)]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This second graph shows as as we move in time (t older) solving our heat equation (blue) is more assimilated to the (red) stationary solution.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: untitled5.jpg|thumb|750px|left|Comparing solutions in &amp;lt;math&amp;gt;t=0,1,2,10&amp;lt;/math&amp;gt;]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
We now show the difference between the previous two solutions stationary real and represented throughout the rod for different values of time. We see how to increasingly large time difference between the two is narrowing, observing the order of magnitude in the ordinate.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: untitled6.jpg|thumb|750px|left|Differences with the stationary solution &amp;lt;math&amp;gt;t=0,1,2,10&amp;lt;/math&amp;gt; order]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Neumann type boundary condition=&lt;br /&gt;
&lt;br /&gt;
Now let's consider a different boundary condition at the right end. Instead of assuming a constant temperature at that end as above, we will place on it an insulating piece. This isolate causes no loss of heat at the right end, that is, the flow temperature is null. This condition is of Neumann type, unlike the previous ones were Dirichlet. So, we keep the condition at the left end and apply the new on the far right, which is&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;-ku_x(3,t)=0 \rightarrow &amp;lt;/math&amp;gt; $\boxed{u_x(3,t)=0}$&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this situation, the temperature of the rod is given by the following problem&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{cases}&lt;br /&gt;
u_t-u_{xx}=0, \qquad x\epsilon(0,3), t&amp;gt;0\\&lt;br /&gt;
u(0,t)=0, u_x(3,t)=0, \qquad t&amp;gt;0\\&lt;br /&gt;
u(x,0)=u_0(x), \qquad x\epsilon[0,3]&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So far in the stationary state for large times the &amp;lt;math&amp;gt; function u (x, t) &amp;lt;/math&amp;gt; that models the temperature of the rod is solution of the following boundary value problem (we call it that because the differential equation depends only &amp;lt;math&amp;gt; x &amp;lt;/math&amp;gt; in the stationary state)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{cases}&lt;br /&gt;
u_{xx}=0, \qquad x\epsilon(0,3), t&amp;gt;0\\&lt;br /&gt;
u(0,t)=0, u_x(3,t)=0, \qquad t&amp;gt;0&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We solve the differential equation to obtain the same result as above&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;u_{xx}=0 \rightarrow u(x,t)=C_1(t)x+C_2(t)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Applying the boundary conditions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;C_1(t)=C_2(t)=0 \rightarrow &amp;lt;/math&amp;gt; $\boxed{u(x,t)=0}$&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This result shows that after a large enough time to consider a steady state in the rod, it acquires a uniform zero temperature. The behavior of the rod is consistent with the boundary conditions, as its final temperature matches that remains constant in the far left.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Finite difference method==&lt;br /&gt;
&lt;br /&gt;
The following image shows an approximation of the problem is shown by the method of finite differences. It can be seen as a high value of the temperature in the rod can be considered constant and uniform throughout, reaching the stationary value &amp;lt;math&amp;gt; u (x, t) = 0 &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo:AP6a.png|thumb|750px|left|Solution of the problem with Neumann type boundary condition]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Specifically, from a time  &amp;lt;math&amp;gt; t = 26.4&amp;lt;/math&amp;gt; we can consider that the temperature reaches stationary value with an error of 0.05, that is, at that moment the difference between the calculated and the thermal distribution stationary takes that value.&lt;br /&gt;
&lt;br /&gt;
Below is reflected Matlab code which approximates the temperature of the rod by using the finite difference method as the implicit Euler that provides a better approximation with a step size  &amp;lt;math&amp;gt; h = 0.1 &amp;lt;/math&amp;gt; in time and space, and &amp;lt;math&amp;gt; t \ in \ mbox {[0,30]} &amp;lt;/math&amp;gt;. Furthermore, in the instant code approximation value differs 0.05 steady in all parts of the rod is calculated.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
clear all&lt;br /&gt;
%Sixth paragraph of labor&lt;br /&gt;
%solve the heat equation ut-uxx = 0 with&lt;br /&gt;
% U (0, t) = 0 ux (L, t) = 0 u (x, 0) = the function piecewise title&lt;br /&gt;
L=3;T=30;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=2*hx;&lt;br /&gt;
K=(2*diag(ones(1,Nx))-diag(ones(1,Nx-1),1)-diag(ones(1,Nx-1),-1));&lt;br /&gt;
K(Nx,Nx-1)=-2;K=K/(hx^2);&lt;br /&gt;
x=hx:hx:L;&lt;br /&gt;
F=zeros(Nx,1);&lt;br /&gt;
t=0:ht:T;&lt;br /&gt;
u0=10*x/3;u0(10:20)=100;&lt;br /&gt;
uu=u0';&lt;br /&gt;
U(1,:)=[0 u0];&lt;br /&gt;
%metoodo de Euler implicito&lt;br /&gt;
for n=1:(length(t)-1)&lt;br /&gt;
 uu=(eye(Nx)+(ht)*K)\(uu+ht*F);&lt;br /&gt;
 U(n+1,:)=[0 uu'];&lt;br /&gt;
end&lt;br /&gt;
p=0.05*ones(1,length(x)+1);&lt;br /&gt;
for i=1:length(t)&lt;br /&gt;
if min(U(i,:)&amp;lt;=p)==1 &lt;br /&gt;
    break &lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
SOL=t(i)&lt;br /&gt;
X=0:hx:L;&lt;br /&gt;
[xx,tt]=meshgrid(X,t);&lt;br /&gt;
surf(xx,tt,U)&lt;br /&gt;
title('Solution of the problem with Neumann type boundary condition')&lt;br /&gt;
xlabel('Space')&lt;br /&gt;
ylabel('Time')&lt;br /&gt;
zlabel('Temperature')&lt;br /&gt;
p=U(:,Nx+1);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Fourier Method==&lt;br /&gt;
&lt;br /&gt;
We propose now the same problem using the Fourier method. Thus, we seek solutions &amp;lt;math&amp;gt; u (x, t) = \ varphi (x) T (t) &amp;lt;/math&amp;gt; form, where &amp;lt;math&amp;gt; \ varphi (x) &amp;lt;/math&amp;gt; must satisfy the following problem eigenvalue&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{cases}&lt;br /&gt;
\varphi’’(x)+\lambda\varphi(x)=0\\&lt;br /&gt;
\varphi(0)=0, \varphi’(3)=0&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The solution of the differential equation is &amp;lt;math&amp;gt;\varphi(x)=a\cos(\sqrt{\lambda}x)+b\sin(\sqrt{\lambda}x)&amp;lt;/math&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Applying the boundary conditions we obtain the eigenvalues &amp;lt;math&amp;gt;\mu_k&amp;lt;/math&amp;gt; and eigenfunctions &amp;lt;math&amp;gt;\varphi_k(x)&amp;lt;/math&amp;gt; of the problem&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\varphi(0)=0 \rightarrow a=0&amp;lt;/math&amp;gt;;&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\varphi’(3)=0 \rightarrow \sqrt{\lambda}\,b\cos(\sqrt{\lambda}\,3)=0 \rightarrow \sqrt{\lambda}\,3=(k-{1\over2})\,\pi \rightarrow &amp;lt;/math&amp;gt; $\boxed{\lambda=\mu_k=(k-{1\over2})^2{\pi^2\over9}}$;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;Así $\boxed{\varphi_k(x)=\sin(k-{1\over2}){\pi\over3}x}$, &amp;lt;math&amp;gt; \qquad k=1,2,3…N&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If we apply that &amp;lt;math&amp;gt; u_k (x, t) = \ varphi_k (x) T_k (t) &amp;lt;/ math&amp;gt; satisfies the differential equation&amp;lt;math&amp;gt;  u_t-u {xx} = 0 &amp;lt;/ math&amp;gt;, we obtain the differential equation determines &amp;lt;math&amp;gt;T_k(t)&amp;lt;/math&amp;gt;&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;u_t-u{xx}=0 \rightarrow \varphi_k(x)T_k’(t)-\varphi_k’’(x)T_k(t)=\varphi_k(x)T_k’(t)-(-\mu_k)\varphi_k(x)T_k(t)=0 \rightarrow &amp;lt;/math&amp;gt; $\boxed{T_k’(t)+\mu_kT_k(t)=0}$&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solution of this differential equation $\boxed{T_k(t)=C_ke^{-\mu_kt}= C_ke^{-(k-{1\over2})^2{\pi^2\over9}t}}$ and therefore &amp;lt;math&amp;gt;u_k(x,t)= \varphi_k(x)T_k(t)=C_ke^{-(k-{1\over2})^2{\pi^2\over9}t}\sin(k-{1\over2}){\pi\over3}x&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If we express the solution of the problem as $ \ boxed {u (x, t) = \sum_ {k = 1} ^ Nu_k (x, t) = \sum_ {k = 1} ^ N ^ C_ke {- (k-{1 \over2}) ^ 2 {\pi ^ 2 \over9} t} \sin (k-{1 \over2}) {\pi \over3} x} $ and make satisfying the initial condition we obtain &amp;lt;math&amp;gt;u(x,0)=\sum_{k=1}^NC_k\sin(k-{1\over2}){\pi\over3}x&amp;lt;/math&amp;gt;. Thus, by uniqueness of the Fourier coefficients, the coefficients &amp;lt;math&amp;gt; C_K &amp;lt;/math&amp;gt; match those of the Fourier series with respect to the eigenfunctions &amp;lt;math&amp;gt; \varphi_k (x) &amp;lt;/math&amp;gt; Function apart that determines the initial condition (expressed at the beginning of the article).&lt;br /&gt;
&lt;br /&gt;
The problem is thus limited to the calculation of these coefficients according to the expression&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;$\boxed{C_k={\int_{0}^{3}u(x,0)\varphi_k(x)dx\over\int_{0}^{3}\varphi_k^2(x)dx}}$&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The degree of accuracy of the approximation with this method depends on the number of elements in the Fourier series, ie, the value of &amp;lt;math&amp;gt; N &amp;lt;/math&amp;gt;. We study the temperature of the rod taking &amp;lt;math&amp;gt;  N = 1,3,5,10,20 &amp;lt;/math&amp;gt; values, as you can see in the picture below. It can be seen, especially in the initial condition, that as the value of &amp;lt;math&amp;gt; N &amp;lt;/math&amp;gt; is the approximate increase function is closer to the real.&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo:Untitled4.jpg|thumb|750px|left|Solutions with different number of terms of the Fourier series]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
These results can be better taking a compare &amp;lt;math&amp;gt;  t = 0.5 &amp;lt;/math&amp;gt; fixed instant, and representing each function it in the same graph, as we see below. For this case we also added the approximation with 2 terms of the Fourier series to reflect that up to 3 terms approaches can be distinguished, but once this number of elements in the series approximations are virtually indistinguishable when compared on the same graph.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[Archivo:Untitled3.jpg|thumb|750px|left|Graph of temperature in t=0.5 with N terms of the Fourier series]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The following Matlab code which approximates the temperature of the rod by the Fourier method, with N = 1,3,5,10,20 terms of the series, and step size is reflected&amp;lt;math&amp;gt;h=0,1&amp;lt;/math&amp;gt; in time and space, and &amp;lt;math&amp;gt;t \in \mbox{[0,10]}&amp;lt;/math&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
clear all&lt;br /&gt;
%Seventh section of the paper&lt;br /&gt;
% solve the heat equation ut-uxx = 0 with&lt;br /&gt;
% U (0, t) = 0 ux (L, t) = 0 u (x, 0) = the function piecewise title&lt;br /&gt;
% Resolution with fourier&lt;br /&gt;
L=3;T=10;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=hx;&lt;br /&gt;
x=0:hx:L;t=0:ht:T;&lt;br /&gt;
[xx,tt]=meshgrid(x,t);&lt;br /&gt;
q=[1,2,3,5,10,20];&lt;br /&gt;
a=[1,3,5,10,20];&lt;br /&gt;
f=10*x/3;f(11:21)=100;&lt;br /&gt;
i=0;&lt;br /&gt;
for Q=q&lt;br /&gt;
u=0;&lt;br /&gt;
for k=1:Q&lt;br /&gt;
    p=sin((k-1/2)*(pi/3)*x);&lt;br /&gt;
    c=trapz(x,f.*p)/trapz(x,p.*p);&lt;br /&gt;
    u=u+c*exp(-((k-1/2)^2)*((pi/3)^2)*tt).*sin((k-1/2)*(pi/3)*xx);&lt;br /&gt;
end&lt;br /&gt;
b=find(Q==a);&lt;br /&gt;
if b&amp;lt;6&lt;br /&gt;
i=i+1;&lt;br /&gt;
figure(1)&lt;br /&gt;
subplot(2,3,i)&lt;br /&gt;
ca=num2str(Q);r=strcat(['Solution with ',ca,' terms of the Fourier series']);&lt;br /&gt;
if Q==1&lt;br /&gt;
r=strcat(['Solution with ',ca,' term of the Fourier series']);&lt;br /&gt;
end&lt;br /&gt;
surf(xx,tt,u),xlabel('Space'),ylabel('Time'),zlabel('Temperature'),title(r)&lt;br /&gt;
end&lt;br /&gt;
d(find(q==Q),:)=u(0.5/ht+1,:);&lt;br /&gt;
end&lt;br /&gt;
figure(2)&lt;br /&gt;
hold on&lt;br /&gt;
title('Temperature in t=0.5 with N terms of the Fourier series')&lt;br /&gt;
plot(x,d(1:6,:))&lt;br /&gt;
xlabel('Space'),ylabel('Time')&lt;br /&gt;
legend('N=1','N=2','N=3','N=5','N=10','N=20','Location','best')&lt;br /&gt;
hold off&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Losses along the rod=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now we will study the case where there are heat sources or sinks along the rod. Specifically, if there is heat loss through the air having a constant temperature of 16 degrees. With the boundary conditions that we had initially keeping the left and right at 0 and 10 degrees respectively ends, the problem would be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{cases}&lt;br /&gt;
u_t-u_{xx}+u-16=0,\ x \in \mbox{[0,3]} &amp;amp;  t&amp;gt;0 \\&lt;br /&gt;
u(0,t)=0; u(3,t)=10; &amp;amp; u(x,0)=g(x) ;&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;math&amp;gt;g(x)&amp;lt;/math&amp;gt;  is defined as in the first problem:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
u_0=&lt;br /&gt;
\begin{cases}&lt;br /&gt;
10x/3 &amp;amp;  \mbox{si}  &amp;amp;  x \in \mbox{(0,1)} \cup \mbox{(2,3)}   \\&lt;br /&gt;
100     &amp;amp;  \mbox{si}  &amp;amp;   x \in \mbox{(1,2)}   &lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To solve the problem by finite differences with a term in &amp;lt;math&amp;gt; u (x, t) &amp;lt;/math&amp;gt; need to rethink the discretization in space:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{cases}&lt;br /&gt;
u’_n(t)+\frac{-u_{n-1}(t)+2u_n(t)-u_{n+1}(t)}{h^2}+u_n(t)=16&amp;amp;n=1,2,…,N&amp;amp;t&amp;gt;0 \\&lt;br /&gt;
u_0(t)=0 \\&lt;br /&gt;
u_N(t)=10 \\&lt;br /&gt;
u_n(0)=g(x)&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus, the resulting matrices are as follows&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
K=&lt;br /&gt;
\begin{pmatrix}&lt;br /&gt;
 2 &amp;amp; -1 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp; 0 &amp;amp; 0 \\&lt;br /&gt;
 -1 &amp;amp; 2 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp;0 &amp;amp; 0 \\&lt;br /&gt;
 … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … \\&lt;br /&gt;
 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp; -1 &amp;amp; 2 &lt;br /&gt;
\end{pmatrix}&lt;br /&gt;
\frac{1}{h^2}+&lt;br /&gt;
\begin{pmatrix} &lt;br /&gt;
1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp; 0 &amp;amp; 0 \\&lt;br /&gt;
0 &amp;amp; 1 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp;0 &amp;amp; 0 \\&lt;br /&gt;
… &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … \\&lt;br /&gt;
0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp; 0 &amp;amp; 1&lt;br /&gt;
\end{pmatrix}&lt;br /&gt;
&amp;lt;/math&amp;gt;; &amp;lt;math&amp;gt;&lt;br /&gt;
F=&lt;br /&gt;
\begin{pmatrix}&lt;br /&gt;
16+\frac{0}{h^2} \\&lt;br /&gt;
16 \\&lt;br /&gt;
… \\&lt;br /&gt;
16+\frac{10}{h^2} \\&lt;br /&gt;
\end{pmatrix}&lt;br /&gt;
&amp;lt;/math&amp;gt;; &amp;lt;math&amp;gt;&lt;br /&gt;
U=&lt;br /&gt;
\begin{pmatrix}&lt;br /&gt;
u_1 \\&lt;br /&gt;
u_2 \\&lt;br /&gt;
… \\&lt;br /&gt;
u_{N-1} \\&lt;br /&gt;
\end{pmatrix}&lt;br /&gt;
&amp;lt;/math&amp;gt;; &amp;lt;math&amp;gt;&lt;br /&gt;
U^0=&lt;br /&gt;
\begin{pmatrix}&lt;br /&gt;
g(x_1) \\&lt;br /&gt;
g(x_2) \\&lt;br /&gt;
… \\&lt;br /&gt;
g(x_{N-1})&lt;br /&gt;
\end{pmatrix}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this we can move to numerically solve the problem, but we must recalculate the steady state of the despising rod &amp;lt;math&amp;gt;u_t(x,t)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;u_t(x,t)\approx 0; \ u_{xx}-u+16=0; \ u(0)=0 \ u(3)=10&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is nothing more than an ordinary differential equation of 2nd order with constant coefficients, whose solution is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;a(t)e^x+b(t)e^{-x}+16&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;math&amp;gt; a (t) &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; b (t) &amp;lt;/math&amp;gt; are constants to be obtained to replace and solve the system with the boundary conditions, which in our case have let him Matlab resolved (see lines 22 and 23 of the code).&lt;br /&gt;
Now, we turn to numerically solve the problem, with &amp;lt;math&amp;gt;h=0,1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;t \in \mbox{[0,10]}&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
clear all&lt;br /&gt;
%solve the heat equation ut-uxx + u-16 = 0 with&lt;br /&gt;
% U (0, t) = 0 u (l, t) = 10 u (x, 0) = the function to set pieces&lt;br /&gt;
L=3;T=10;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=hx;&lt;br /&gt;
K=(2*diag(ones(1,Nx-1))-diag(ones(1,Nx-2),1)-diag(ones(1,Nx-2),-1))/(hx^2);&lt;br /&gt;
K=K+eye(Nx-1);&lt;br /&gt;
x=hx:hx:L-hx;&lt;br /&gt;
F=16*ones(Nx-1,1);F(Nx-1)=16+10/(hx^2);&lt;br /&gt;
t=0:ht:T;&lt;br /&gt;
u0=10*x/3;u0(10:20)=100;&lt;br /&gt;
uu=u0';&lt;br /&gt;
U(1,:)=[0 u0 10];&lt;br /&gt;
%metoodo de Euler implicito&lt;br /&gt;
for n=1:(length(t)-1)&lt;br /&gt;
 uu=(eye(Nx-1)+(ht)*K)\(uu+ht*F);&lt;br /&gt;
 U(n+1,:)=[0 uu' 10];&lt;br /&gt;
end&lt;br /&gt;
X=0:hx:L;&lt;br /&gt;
[xx,tt]=meshgrid(X,t);&lt;br /&gt;
a=[1 1;exp(3) exp(-3)];b=[-16;-6];d=a\b;&lt;br /&gt;
V=d(1)*exp(xx)+d(2)*exp(-xx)+16*ones(T/ht+1,Nx+1);&lt;br /&gt;
figure(1)&lt;br /&gt;
hold on&lt;br /&gt;
surf(xx,tt,U)&lt;br /&gt;
xlabel('space')&lt;br /&gt;
ylabel('time')&lt;br /&gt;
zlabel('temperature')&lt;br /&gt;
h1=surf(xx,tt,V),set(h1,'FaceColor','red','FaceAlpha',0.5,'EdgeColor','w')&lt;br /&gt;
xlabel('space')&lt;br /&gt;
ylabel('time')&lt;br /&gt;
zlabel('temperature')&lt;br /&gt;
E=abs(U-V);&lt;br /&gt;
e1=E(46:101,Nx/6+1);&lt;br /&gt;
e2=E(46:101,Nx/3+1);&lt;br /&gt;
e3=E(46:101,Nx/2+1);&lt;br /&gt;
e4=E(46:101,2*Nx/3+1);&lt;br /&gt;
e5=E(46:101,5*Nx/6+1);&lt;br /&gt;
figure(3)&lt;br /&gt;
hold on&lt;br /&gt;
plot(t(46:101),e1)&lt;br /&gt;
plot(t(46:101),e2,'r')&lt;br /&gt;
plot(t(46:101),e3,'k')&lt;br /&gt;
plot(t(46:101),e4,'m')&lt;br /&gt;
plot(t(46:101),e5,'c'),legend('Difference in x=0.5','Difference in x=1',...&lt;br /&gt;
'Difference in x=1.5','Difference in x=2','Difference in x=2.5')&lt;br /&gt;
plot(t(46:101),0.001*ones(1,length(t)-45),'g'),xlabel('time'),...&lt;br /&gt;
ylabel('Difference with the stationary solution')&lt;br /&gt;
hold off&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo:Untitled002.jpg|thumb|750px|left|Graph of &amp;lt;math&amp;gt;u(x,t)&amp;lt;/math&amp;gt;  in &amp;lt;math&amp;gt;x \in \mbox{[0,3]};t \in \mbox{[0,10]}&amp;lt;/math&amp;gt;. In pink is the stationary solution. ]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
As shown in the graph, the actual solution and stationary are virtually identical for &amp;lt;math&amp;gt;  t&amp;gt; 2 &amp;lt;/math&amp;gt;. Furthermore we see that near &amp;lt;math&amp;gt; t = 5 &amp;lt;/math&amp;gt; the stationary solution is above the real solution. This is best seen in the following graph in which are represented the difference between the actual solution and the stationary for different values of &amp;lt;math&amp;gt;  x &amp;lt;/math&amp;gt;, namely &amp;lt;math&amp;gt;x = 0.5,1,1.5,2,2.5  &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo:Untitled01.jpg|thumb|750px|left|Graph with the difference between the real and the stationary solution for&amp;lt;math&amp;gt;t \in \mbox{[4.5,10]}&amp;lt;/math&amp;gt; ]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
At that point cut the difference between the two is minimal, below &amp;lt;math&amp;gt; 10 ^ {-3 } &amp;lt;/math&amp;gt;, while from there this difference increases slightly and remained constant when time is increasing. This was expected, since for large times the solution of the equation is stationary, and therefore effects of time we have is the difference between two constants. The existing small difference between the two may be because logically, does not disclose exact thing but we are solving the equation numerically.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Changing the boundary conditions==&lt;br /&gt;
&lt;br /&gt;
Suppose now that we change the boundary conditions, so that now the left end of the rod to be in contact with a material whose temperature varies according to the function &amp;lt;math&amp;gt; 10sen (t) &amp;lt;/math&amp;gt;, and by the end right there is a flow of constant heat input &amp;lt;math&amp;gt; 1 &amp;lt;/math&amp;gt;. These conditions translate as &amp;lt;math&amp;gt; u (0, t) = 10sen (t) &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; u_x (3, t) = 1 &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
As the second condition of Neumann type, size of the matrices increases one unit, to be known &amp;lt;math&amp;gt; u_n &amp;lt;/math&amp;gt; term. Also &amp;lt;math&amp;gt; K &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; F &amp;lt;/math&amp;gt; change their terms, becoming&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
K=&lt;br /&gt;
\begin{pmatrix}&lt;br /&gt;
 2 &amp;amp; -1 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp; 0 &amp;amp; 0 \\&lt;br /&gt;
 -1 &amp;amp; 2 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp;0 &amp;amp; 0 \\&lt;br /&gt;
 … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … \\&lt;br /&gt;
 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp; -2 &amp;amp; 2 &lt;br /&gt;
\end{pmatrix}&lt;br /&gt;
\frac{1}{h^2}+&lt;br /&gt;
\begin{pmatrix} &lt;br /&gt;
1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp; 0 &amp;amp; 0 \\&lt;br /&gt;
0 &amp;amp; 1 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp;0 &amp;amp; 0 \\&lt;br /&gt;
… &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … \\&lt;br /&gt;
0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp; 0 &amp;amp; 1&lt;br /&gt;
\end{pmatrix}&lt;br /&gt;
&amp;lt;/math&amp;gt;; &amp;lt;math&amp;gt;&lt;br /&gt;
F=&lt;br /&gt;
\begin{pmatrix}&lt;br /&gt;
16+\frac{10sen(t_n)}{h^2} \\&lt;br /&gt;
16 \\&lt;br /&gt;
… \\&lt;br /&gt;
16+\frac{2}{h} \\&lt;br /&gt;
\end{pmatrix}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We solve the implicit Euler method with &amp;lt;math&amp;gt;h=0,1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;t \in \mbox{[0,10]}&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
clear all&lt;br /&gt;
%solve the heat equation ut-uxx + u-16 = 0 with&lt;br /&gt;
% U (0, t) = 10 * sin (t) ux (L, t) = 1 u (x, 0) = the function piecewise title&lt;br /&gt;
L=3;T=10;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=hx;&lt;br /&gt;
K=(2*diag(ones(1,Nx))-diag(ones(1,Nx-1),1)-diag(ones(1,Nx-1),-1));K(Nx,Nx-1)=-2;K=K/(hx^2);&lt;br /&gt;
K=K+eye(Nx);&lt;br /&gt;
x=hx:hx:L;&lt;br /&gt;
t=0:ht:T;&lt;br /&gt;
u0=10*x/3;u0(10:20)=100;&lt;br /&gt;
uu=u0';&lt;br /&gt;
g=10*sin(t);&lt;br /&gt;
U(1,:)=[g(1) u0];&lt;br /&gt;
%implicit Euler method&lt;br /&gt;
for n=1:(length(t)-1)&lt;br /&gt;
   F=16*ones(Nx,1);F(Nx)=16+2/hx;F(1)=16+g(n)/(hx^2);&lt;br /&gt;
   uu=(eye(Nx)+(ht)*K)\(uu+ht*F);&lt;br /&gt;
   U(n+1,:)=[g(n+1) uu'];&lt;br /&gt;
end&lt;br /&gt;
X=0:hx:L;&lt;br /&gt;
[xx,tt]=meshgrid(X,t);&lt;br /&gt;
figure(1)&lt;br /&gt;
surf(xx,tt,U)&lt;br /&gt;
xlabel('space')&lt;br /&gt;
ylabel('time')&lt;br /&gt;
zlabel('Temperature')&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo:untitled.jpg|thumb|750px|left|Graph of &amp;lt;math&amp;gt;u(x,t)&amp;lt;/math&amp;gt;  in &amp;lt;math&amp;gt;x \in \mbox{[0,3]};t \in \mbox{[0,10]}&amp;lt;/math&amp;gt; ]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In view of the graph we can conclude that as previously when we had a Neumann type condition, the heat &amp;quot;escapes&amp;quot; from the left end at a variable temperature with time while entering from the right. This can be seen if the program is run on the graph by observing the slight slope that the surface of temperatures has at the left side.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Categoría:Ecuaciones Diferenciales]]&lt;br /&gt;
[[Categoría:ED13/14]]&lt;br /&gt;
[[Categoría:Trabajos 2013-14]]&lt;/div&gt;</summary>
		<author><name>Marino Rivera</name></author>	</entry>

	<entry>
		<id>https://mat.caminos.upm.es/w/index.php?title=Heat_equation&amp;diff=12232</id>
		<title>Heat equation</title>
		<link rel="alternate" type="text/html" href="https://mat.caminos.upm.es/w/index.php?title=Heat_equation&amp;diff=12232"/>
				<updated>2014-05-18T17:11:07Z</updated>
		
		<summary type="html">&lt;p&gt;Marino Rivera: Marino Rivera movió la página Heat equation a Heat equation (Grupo 1B)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECCIÓN [[Heat equation (Grupo 1B)]]&lt;/div&gt;</summary>
		<author><name>Marino Rivera</name></author>	</entry>

	<entry>
		<id>https://mat.caminos.upm.es/w/index.php?title=Heat_equation_(Grupo_1B)&amp;diff=12220</id>
		<title>Heat equation (Grupo 1B)</title>
		<link rel="alternate" type="text/html" href="https://mat.caminos.upm.es/w/index.php?title=Heat_equation_(Grupo_1B)&amp;diff=12220"/>
				<updated>2014-05-18T17:02:06Z</updated>
		
		<summary type="html">&lt;p&gt;Marino Rivera: Página creada con «{{ TrabajoED |Heat equation. Grupo 1-B | Ecuaciones Diferenciales|Curso 2013-14 | Sandro Andrés Martínez ...»&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ TrabajoED |Heat equation. Grupo 1-B | [[:Categoría:Ecuaciones Diferenciales|Ecuaciones Diferenciales]]|[[:Categoría:ED13/14|Curso 2013-14]] | Sandro Andrés Martínez &lt;br /&gt;
 &lt;br /&gt;
David Ayala Díez &lt;br /&gt;
 &lt;br /&gt;
Claudia Cózar Coarasa  &lt;br /&gt;
&lt;br /&gt;
Lorena de la Fuente Sanz  &lt;br /&gt;
&lt;br /&gt;
Marino Rivera Muñoz &lt;br /&gt;
  &lt;br /&gt;
José Manuel Torres Serrano }}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this work we have studied the modeling of the heat equation, according to Fourier's law discovered in the nineteenth century.&lt;br /&gt;
&lt;br /&gt;
= Well proposed problem  =&lt;br /&gt;
&lt;br /&gt;
[[Archivo:Nueva imagen.png|thumb|300px|left| Thin rod of length L]]&lt;br /&gt;
&lt;br /&gt;
We will raise the system of equations that satisfies &amp;lt;math&amp;gt;u(x,t)&amp;lt;/math&amp;gt; assuming that the temperature of the rod &amp;lt;math&amp;gt;u(x,t)&amp;lt;/math&amp;gt; satisfies the heat equation &amp;lt;math&amp;gt;u_t-u_{xx}=0&amp;lt;/math&amp;gt;. First, we have a thin, homogeneous and thermally isolated by its lateral surface rod of length  &amp;lt;math&amp;gt;L=3&amp;lt;/math&amp;gt;. At its left end the rod is in contact with a material whose temperature is maintained at 0°C, while the right is in contact with the material at 10°C. We also know that at the initial moment, the temperature distribution follows the &amp;lt;math&amp;gt;u(x,0)=u_0(x)&amp;lt;/math&amp;gt; function specified below. Assuming a standard &amp;lt;math&amp;gt;c=\rho=k=1&amp;lt;/math&amp;gt; parameters and there are no heat sources or sinks along the rod, the problem we have to solve is:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;math&amp;gt;&lt;br /&gt;
(P)&lt;br /&gt;
\begin{cases}&lt;br /&gt;
u_t-u_{xx}=0, \qquad x\epsilon(0,3), t&amp;gt;0\\&lt;br /&gt;
u(0,t)=0, u(3,t)=10, \qquad t&amp;gt;0\\&lt;br /&gt;
u(x,0)=u_0(x), \qquad x\epsilon[0,3]&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
:&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
u_0(x)=&lt;br /&gt;
\begin{cases}&lt;br /&gt;
10x/3 &amp;amp;  \mbox{si}  &amp;amp;  x \in \mbox{(0,1)}\cup\mbox{(2,3)}   \\&lt;br /&gt;
100     &amp;amp;  \mbox{si}  &amp;amp;   x \in \mbox{(1,2)}   &lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Then we will define what is a well proposed problem is one that meets the following:&lt;br /&gt;
&lt;br /&gt;
•	Existence: problem &amp;lt;math&amp;gt;(P)&amp;lt;/math&amp;gt; admits a solution &amp;lt;math&amp;gt;u(x,t)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
•	Uniqueness: if there is a solution &amp;lt;math&amp;gt;(P)&amp;lt;/math&amp;gt; it has to be unique.&lt;br /&gt;
&lt;br /&gt;
•	Stability with respect to initial data: &lt;br /&gt;
We consider the problem:&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
(P_1)&lt;br /&gt;
\begin{cases}&lt;br /&gt;
u_t-u_{xx}=0, \qquad x\epsilon(0,3), t&amp;gt;0\\&lt;br /&gt;
u(0,t)=0, u(3,t)=10, \qquad t&amp;gt;0\\&lt;br /&gt;
u(x,0)=h(x), \qquad x\epsilon[0,3]&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Be &amp;lt;math&amp;gt;u(x,t)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;u_1(x,t)&amp;lt;/math&amp;gt; &amp;lt;math&amp;gt;(P)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;(P_1)&amp;lt;/math&amp;gt; solutions respectively. We say that the &amp;lt;math&amp;gt;(P)&amp;lt;/math&amp;gt; problem is stable with respect to initial data if we prove the inequality of type &amp;lt;math&amp;gt;sup_{(x,t)\in [0,3]x[0,\infty]}\left|u(x,t)-u_1(x,t)\right|\leq Csup_{(x,t)\in [0,3]x[0,\infty]}\left|u_0(x)-h(x)\right|&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; absolute, constant independent of the &amp;lt;math&amp;gt;(P)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;(P_1)&amp;lt;/math&amp;gt; problems.&lt;br /&gt;
&lt;br /&gt;
That &amp;lt;math&amp;gt; (P) &amp;lt;/math&amp;gt; is stable with respect to initial data tells us that if &amp;lt;math&amp;gt; h (x) &amp;lt;/math&amp;gt; is close to &amp;lt;math&amp;gt; u_0 (x) &amp;lt;/math&amp;gt; in the sense that &amp;lt;math&amp;gt; sup_ {(x, t) \ in [0,3] x [0, \infty]} \left | u_0 (x)-h (x) \right | &amp;lt;/math&amp;gt; is small, then the &amp;lt;math&amp;gt;  u (x, t) &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; u_1 (x, t) &amp;lt;/math&amp;gt; solutions are also nearby.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Resolution establishing finite difference method==&lt;br /&gt;
&lt;br /&gt;
Then the MATLAB code that numerically solves the heat equation posed exposed. It has been solved by the finite difference method with &amp;lt;math&amp;gt; \Delta x = 0.1 &amp;lt;/math&amp;gt; and we have used the method of taking time trapeze &amp;lt;math&amp;gt; \Delta t = \Delta x &amp;lt;/math&amp;gt;. The number of subintervals in which we divide the rod length is &amp;lt;math&amp;gt; Nx = 30 &amp;lt;/math&amp;gt; and time to which we have taken to represent &amp;lt;math&amp;gt; 2 &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
clear all&lt;br /&gt;
%solve the heat equation ut-uxx = 0 with&lt;br /&gt;
% u(0,t)=0 u(l,t)=10 u(x,0)=the piecewise title&lt;br /&gt;
L=3;T=2;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=hx;&lt;br /&gt;
K=(2*diag(ones(1,Nx-1))-diag(ones(1,Nx-2),1)-diag(ones(1,Nx-2),-1))/(hx^2);&lt;br /&gt;
x=hx:hx:L-hx;&lt;br /&gt;
F=zeros(Nx-1,1);F(Nx-1)=10/(hx^2);&lt;br /&gt;
t=0:ht:T;&lt;br /&gt;
u0=10*x/3;u0(10:20)=100;&lt;br /&gt;
uu=u0';&lt;br /&gt;
U(1,:)=[0 u0 10];&lt;br /&gt;
%method of trapezoids&lt;br /&gt;
for n=1:(length(t)-1)&lt;br /&gt;
 uu=(eye(Nx-1)+(ht/2)*K)\(uu+ht*(-K*uu+F+F)/2);&lt;br /&gt;
 U(n+1,:)=[0 uu' 10];&lt;br /&gt;
end&lt;br /&gt;
X=0:hx:L;&lt;br /&gt;
[xx,tt]=meshgrid(X,t);&lt;br /&gt;
m=U(:,16);&lt;br /&gt;
figure(1)&lt;br /&gt;
surf(xx,tt,U)&lt;br /&gt;
xlabel('space')&lt;br /&gt;
ylabel('time')&lt;br /&gt;
zlabel('temperature')&lt;br /&gt;
figure(2)&lt;br /&gt;
plot(t,m)&lt;br /&gt;
xlabel('time')&lt;br /&gt;
ylabel('temperature')&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
In this graph we have shown the 3D surface of the solution of the heat equation posed. As shown, although the trapezoidal method is an implicit method, not well approximated by the points of discontinuity of the initial condition and require less in the discretization step to remove these &amp;quot;peaks&amp;quot; that appear on the surface.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[Archivo: untitled11.jpg|thumb|750px|left|Solution of the heat equation]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the graph shown below the temperature behavior is shown in the middle of the rod with time. This is also obtained from the upper MATLAB code. Comparing the two graphs shows that the latter is a cut &amp;lt;math&amp;gt; x = 1.5 &amp;lt;/math&amp;gt; of the above.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[Archivo: gráfica3a.jpg|thumb|750px|left| u(t) ]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Resolution with different methods =&lt;br /&gt;
&lt;br /&gt;
We will solve the problem initially posed by the implicit and explicit methods by Euler and Runge-Kutta of order 4, following the same steps as with the method of the Trapezium.&lt;br /&gt;
&lt;br /&gt;
==Implicit Euler==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
&lt;br /&gt;
clear all&lt;br /&gt;
%solve the heat equation ut-uxx = 0 with&lt;br /&gt;
% u(0,t)=0 u(l,t)=10 u(x,0)=the piecewise title&lt;br /&gt;
L=3;T=2;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=hx;&lt;br /&gt;
K=(2*diag(ones(1,Nx-1))-diag(ones(1,Nx-2),1)-diag(ones(1,Nx-2),-1))/(hx^2);&lt;br /&gt;
x=hx:hx:L-hx;&lt;br /&gt;
F=zeros(Nx-1,1);F(Nx-1)=10/(hx^2);&lt;br /&gt;
t=0:ht:T;&lt;br /&gt;
u0=10*x/3;u0(10:20)=100;&lt;br /&gt;
uu=u0';&lt;br /&gt;
U(1,:)=[0 u0 10];&lt;br /&gt;
%implicit Euler method&lt;br /&gt;
for n=1:(length(t)-1)&lt;br /&gt;
 uu=(eye(Nx-1)+(ht)*K)\(uu+ht*F);&lt;br /&gt;
 U(n+1,:)=[0 uu' 10];&lt;br /&gt;
end&lt;br /&gt;
X=0:hx:L;&lt;br /&gt;
[xx,tt]=meshgrid(X,t);&lt;br /&gt;
m=U(:,16);&lt;br /&gt;
figure(1)&lt;br /&gt;
surf(xx,tt,U)&lt;br /&gt;
xlabel('space')&lt;br /&gt;
ylabel('time')&lt;br /&gt;
zlabel('temperature')&lt;br /&gt;
figure(2)&lt;br /&gt;
plot(t,m)&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: untitled00010.jpg|thumb|750px|left|Surface with the implicit Euler method]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: Grafica_Euler_impl%C3%ADcito.jpg |thumb|750px|left|&amp;lt;math&amp;gt; x = 1.5 &amp;lt;/math&amp;gt; Graph with the implicit Euler method]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Explicit Euler==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
&lt;br /&gt;
clear all&lt;br /&gt;
% Explicit Euler method&lt;br /&gt;
L=3;T=2;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=(hx^2)/2;% must do so, if not it does not work&lt;br /&gt;
K=(2*diag(ones(1,Nx-1))-diag(ones(1,Nx-2),1)-diag(ones(1,Nx-2),-1))/(hx^2);&lt;br /&gt;
x=hx:hx:L-hx;&lt;br /&gt;
F=zeros(Nx-1,1);F(Nx-1)=10/(hx^2);&lt;br /&gt;
t=0:ht:T;&lt;br /&gt;
u0=10*x/3;u0(10:20)=100;&lt;br /&gt;
uu=u0';&lt;br /&gt;
U(1,:)=[0 u0 10];&lt;br /&gt;
for n=1:(length(t)-1)&lt;br /&gt;
 uu=uu+ht*(-K*uu+F);&lt;br /&gt;
 U(n+1,:)=[0 uu' 10];&lt;br /&gt;
end&lt;br /&gt;
X=0:hx:L;&lt;br /&gt;
[xx,tt]=meshgrid(X,t);&lt;br /&gt;
m=U(:,16);&lt;br /&gt;
figure(3)&lt;br /&gt;
surf(xx,tt,U)&lt;br /&gt;
xlabel('space')&lt;br /&gt;
ylabel('time')&lt;br /&gt;
zlabel('Temperature')&lt;br /&gt;
figure(4)&lt;br /&gt;
plot(t,m)&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: untitled9.jpg|thumb|750px|left|Surface with explicit Euler method ]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: Euler1.3.jpg |thumb|750px|left|Graph in &amp;lt;math&amp;gt;x=1.5&amp;lt;/math&amp;gt; with explicit Euler method]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Runge-Kutta==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
&lt;br /&gt;
clear all&lt;br /&gt;
% Runge Kutta method&lt;br /&gt;
L=3;T=2;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=(hx^2)/2;% if we do not add ht it does not work&lt;br /&gt;
K=(2*diag(ones(1,Nx-1))-diag(ones(1,Nx-2),1)-diag(ones(1,Nx-2),-1))/(hx^2);&lt;br /&gt;
x=hx:hx:L-hx;&lt;br /&gt;
F=zeros(Nx-1,1);F(Nx-1)=10/(hx^2);&lt;br /&gt;
t=0:ht:T;&lt;br /&gt;
u0=10*x/3;u0(10:20)=100;&lt;br /&gt;
uu=u0';&lt;br /&gt;
U(1,:)=[0 u0 10];&lt;br /&gt;
for n=1:(length(t)-1)&lt;br /&gt;
 k1=-K*uu+F;&lt;br /&gt;
 k2=-K*(uu+k1*ht/2)+F;&lt;br /&gt;
 k3=-K*(uu+k2*ht/2)+F;&lt;br /&gt;
 k4=-K*(uu+k3*ht)+F;&lt;br /&gt;
 uu=uu+(ht/6)*(k1+2*k2+2*k3+k4);&lt;br /&gt;
 U(n+1,:)=[0 uu' 10];&lt;br /&gt;
end&lt;br /&gt;
X=0:hx:L;&lt;br /&gt;
[xx,tt]=meshgrid(X,t);&lt;br /&gt;
m=U(:,16);&lt;br /&gt;
figure(5)&lt;br /&gt;
surf(xx,tt,U)&lt;br /&gt;
xlabel('space')&lt;br /&gt;
ylabel('time')&lt;br /&gt;
zlabel('Temperature')&lt;br /&gt;
figure(6)&lt;br /&gt;
plot(t,m)&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: untitled8.jpg|thumb|750px|left|Surface with Runge Kutta method]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: Grafica_Runge_Kutta.jpeg|thumb|750px|left|Graph in &amp;lt;math&amp;gt;x=1.5&amp;lt;/math&amp;gt; Runge Kutta method]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can see that the method that works best is the implicit Euler, whereas explicit Euler and Runge-Kutta, being explicit methods require a rodent control into smaller intervals, and still not a good approximation is achieved as can be seen in the graph of the explicit Euler method. Therefore, for what follows, we use implicit Euler method.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Stationary state=&lt;br /&gt;
&lt;br /&gt;
It is said that a physical system is in stationary state when its characteristics do not vary with time. In this section we address this stationary state, which consists of neglecting the time and see what happens to our problem without taking into account the time variable.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;u_t(x,t)\approx 0; \ u_{xx}=0; \ u_x=c_1(t) \ u=c_1(t)x+c_2(t)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Substituting the boundary conditions:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;u(0)=0; \ c_2(t)=0; \ u(3)=10; \ c_1(t)=\frac{10}{3}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Thus the stationary solution is &amp;lt;math&amp;gt; u (x, t) = \ frac {10x} {3} &amp;lt;/math&amp;gt;, which is related to the initial condition. It seems logical that once the temperature in the center of the rod has dissipated, the ends having this constant temperature varies linearly between the two.&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
&lt;br /&gt;
clear all&lt;br /&gt;
%solve the heat equation ut-uxx = 0 with&lt;br /&gt;
% u(0,t)=0 u(l,t)=10 u(x,0)=the piecewise title&lt;br /&gt;
L=3;T=10;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=hx;&lt;br /&gt;
K=(2*diag(ones(1,Nx-1))-diag(ones(1,Nx-2),1)-diag(ones(1,Nx-2),-1))/(hx^2);&lt;br /&gt;
x=hx:hx:L-hx;&lt;br /&gt;
F=zeros(Nx-1,1);F(Nx-1)=10/(hx^2);&lt;br /&gt;
t=0:ht:T;&lt;br /&gt;
u0=10*x/3;u0(10:20)=100;&lt;br /&gt;
uu=u0';&lt;br /&gt;
U(1,:)=[0 u0 10];&lt;br /&gt;
%método de Euler implícito&lt;br /&gt;
for n=1:(length(t)-1)&lt;br /&gt;
 uu=(eye(Nx-1)+(ht)*K)\(uu+ht*F);&lt;br /&gt;
 U(n+1,:)=[0 uu' 10];&lt;br /&gt;
end&lt;br /&gt;
X=0:hx:L;&lt;br /&gt;
[xx,tt]=meshgrid(X,t);&lt;br /&gt;
%solución estacionaria u(x)=10/3*x&lt;br /&gt;
V=10*xx/3;&lt;br /&gt;
figure(1)&lt;br /&gt;
hold on&lt;br /&gt;
surf(xx,tt,U)&lt;br /&gt;
xlabel('space')&lt;br /&gt;
ylabel('time')&lt;br /&gt;
zlabel('Temperature')&lt;br /&gt;
h1=surf(xx,tt,V),set(h1,'FaceColor','magenta','FaceAlpha',0.5,'EdgeColor','w')&lt;br /&gt;
hold off&lt;br /&gt;
t0=U(1,:);t1=U(1/ht+1,:);t2=U(2/ht+1,:);t10=U(10/ht+1,:);&lt;br /&gt;
figure(2)&lt;br /&gt;
subplot(2,2,1)&lt;br /&gt;
hold on&lt;br /&gt;
plot(X,t0)&lt;br /&gt;
plot(X,V(1,:),'r')&lt;br /&gt;
xlabel('x')&lt;br /&gt;
ylabel('temperature with t=0')&lt;br /&gt;
hold off&lt;br /&gt;
subplot(2,2,2)&lt;br /&gt;
hold on&lt;br /&gt;
plot(X,t1)&lt;br /&gt;
plot(X,V(1+1/ht,:),'r')&lt;br /&gt;
xlabel('x')&lt;br /&gt;
ylabel('temperature with t=1')&lt;br /&gt;
hold off&lt;br /&gt;
subplot(2,2,3)&lt;br /&gt;
hold on&lt;br /&gt;
plot(X,t2)&lt;br /&gt;
plot(X,V(1+2/ht,:),'r')&lt;br /&gt;
xlabel('x')&lt;br /&gt;
ylabel('temperature with t=2')&lt;br /&gt;
hold off&lt;br /&gt;
subplot(2,2,4)&lt;br /&gt;
hold on&lt;br /&gt;
plot(X,t10)&lt;br /&gt;
plot(X,V(1+10/ht,:),'r')&lt;br /&gt;
xlabel('x')&lt;br /&gt;
ylabel('temperature with t=10')&lt;br /&gt;
hold off&lt;br /&gt;
figure(3)&lt;br /&gt;
subplot(2,2,1)&lt;br /&gt;
e1=abs(t0-V(1,:));me1=max(e1);...&lt;br /&gt;
sprintf('The maximum difference with the stationary solution in t=0 is %d .',me1)&lt;br /&gt;
plot(X,e1,'g'),xlabel('x'),...&lt;br /&gt;
ylabel('Difference with the stationary solution in t=0') &lt;br /&gt;
subplot(2,2,2)&lt;br /&gt;
e2=abs(t1-V(1+1/ht,:));me2=max(e2);...&lt;br /&gt;
sprintf('The maximum difference with the stationary solution in t=1 is %d .',me2)&lt;br /&gt;
plot(X,e2,'g'),xlabel('x'),...&lt;br /&gt;
ylabel('Difference with the stationary solution t=1') &lt;br /&gt;
subplot(2,2,3)&lt;br /&gt;
e3=abs(t2-V(1+2/ht,:));me3=max(e3);...&lt;br /&gt;
sprintf('The maximum difference with the stationary solution in t=2 is %d .',me3)&lt;br /&gt;
plot(X,e3,'g'),xlabel('x'),...&lt;br /&gt;
ylabel('Difference with the stationary solution in t=2') &lt;br /&gt;
subplot(2,2,4)&lt;br /&gt;
e4=abs(t10-V(1+10/ht,:));me4=max(e4);...&lt;br /&gt;
sprintf('The maximum difference with the stationary solution in t=10 is %d .',me4)&lt;br /&gt;
plot(X,e4,'g'),xlabel('x'),ylabel('Difference with the stationary solution in t=10') &lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: untitled7.jpg|thumb|750px|left|Real surfaces and the stationary solution (in pink)]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This second graph shows as as we move in time (t older) solving our heat equation (blue) is more assimilated to the (red) stationary solution.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: untitled5.jpg|thumb|750px|left|Comparing solutions in &amp;lt;math&amp;gt;t=0,1,2,10&amp;lt;/math&amp;gt;]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
We now show the difference between the previous two solutions stationary real and represented throughout the rod for different values of time. We see how to increasingly large time difference between the two is narrowing, observing the order of magnitude in the ordinate.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo: untitled6.jpg|thumb|750px|left|Differences with the stationary solution &amp;lt;math&amp;gt;t=0,1,2,10&amp;lt;/math&amp;gt; order]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Neumann type boundary condition=&lt;br /&gt;
&lt;br /&gt;
Now let's consider a different boundary condition at the right end. Instead of assuming a constant temperature at that end as above, we will place on it an insulating piece. This isolate causes no loss of heat at the right end, that is, the flow temperature is null. This condition is of Neumann type, unlike the previous ones were Dirichlet. So, we keep the condition at the left end and apply the new on the far right, which is&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;-ku_x(3,t)=0 \rightarrow &amp;lt;/math&amp;gt; $\boxed{u_x(3,t)=0}$&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this situation, the temperature of the rod is given by the following problem&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{cases}&lt;br /&gt;
u_t-u_{xx}=0, \qquad x\epsilon(0,3), t&amp;gt;0\\&lt;br /&gt;
u(0,t)=0, u_x(3,t)=0, \qquad t&amp;gt;0\\&lt;br /&gt;
u(x,0)=u_0(x), \qquad x\epsilon[0,3]&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So far in the stationary state for large times the &amp;lt;math&amp;gt; function u (x, t) &amp;lt;/math&amp;gt; that models the temperature of the rod is solution of the following boundary value problem (we call it that because the differential equation depends only &amp;lt;math&amp;gt; x &amp;lt;/math&amp;gt; in the stationary state)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{cases}&lt;br /&gt;
u_{xx}=0, \qquad x\epsilon(0,3), t&amp;gt;0\\&lt;br /&gt;
u(0,t)=0, u_x(3,t)=0, \qquad t&amp;gt;0&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We solve the differential equation to obtain the same result as above&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;u_{xx}=0 \rightarrow u(x,t)=C_1(t)x+C_2(t)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Applying the boundary conditions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;C_1(t)=C_2(t)=0 \rightarrow &amp;lt;/math&amp;gt; $\boxed{u(x,t)=0}$&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This result shows that after a large enough time to consider a steady state in the rod, it acquires a uniform zero temperature. The behavior of the rod is consistent with the boundary conditions, as its final temperature matches that remains constant in the far left.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Finite difference method==&lt;br /&gt;
&lt;br /&gt;
The following image shows an approximation of the problem is shown by the method of finite differences. It can be seen as a high value of the temperature in the rod can be considered constant and uniform throughout, reaching the stationary value &amp;lt;math&amp;gt; u (x, t) = 0 &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo:AP6a.png|thumb|750px|left|Solution of the problem with Neumann type boundary condition]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Specifically, from a time  &amp;lt;math&amp;gt; t = 26.4&amp;lt;/math&amp;gt; we can consider that the temperature reaches stationary value with an error of 0.05, that is, at that moment the difference between the calculated and the thermal distribution stationary takes that value.&lt;br /&gt;
&lt;br /&gt;
Below is reflected Matlab code which approximates the temperature of the rod by using the finite difference method as the implicit Euler that provides a better approximation with a step size  &amp;lt;math&amp;gt; h = 0.1 &amp;lt;/math&amp;gt; in time and space, and &amp;lt;math&amp;gt; t \ in \ mbox {[0,30]} &amp;lt;/math&amp;gt;. Furthermore, in the instant code approximation value differs 0.05 steady in all parts of the rod is calculated.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
clear all&lt;br /&gt;
%Sixth paragraph of labor&lt;br /&gt;
%solve the heat equation ut-uxx = 0 with&lt;br /&gt;
% U (0, t) = 0 ux (L, t) = 0 u (x, 0) = the function piecewise title&lt;br /&gt;
L=3;T=30;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=2*hx;&lt;br /&gt;
K=(2*diag(ones(1,Nx))-diag(ones(1,Nx-1),1)-diag(ones(1,Nx-1),-1));&lt;br /&gt;
K(Nx,Nx-1)=-2;K=K/(hx^2);&lt;br /&gt;
x=hx:hx:L;&lt;br /&gt;
F=zeros(Nx,1);&lt;br /&gt;
t=0:ht:T;&lt;br /&gt;
u0=10*x/3;u0(10:20)=100;&lt;br /&gt;
uu=u0';&lt;br /&gt;
U(1,:)=[0 u0];&lt;br /&gt;
%metoodo de Euler implicito&lt;br /&gt;
for n=1:(length(t)-1)&lt;br /&gt;
 uu=(eye(Nx)+(ht)*K)\(uu+ht*F);&lt;br /&gt;
 U(n+1,:)=[0 uu'];&lt;br /&gt;
end&lt;br /&gt;
p=0.05*ones(1,length(x)+1);&lt;br /&gt;
for i=1:length(t)&lt;br /&gt;
if min(U(i,:)&amp;lt;=p)==1 &lt;br /&gt;
    break &lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
SOL=t(i)&lt;br /&gt;
X=0:hx:L;&lt;br /&gt;
[xx,tt]=meshgrid(X,t);&lt;br /&gt;
surf(xx,tt,U)&lt;br /&gt;
title('Solution of the problem with Neumann type boundary condition')&lt;br /&gt;
xlabel('Space')&lt;br /&gt;
ylabel('Time')&lt;br /&gt;
zlabel('Temperature')&lt;br /&gt;
p=U(:,Nx+1);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Fourier Method==&lt;br /&gt;
&lt;br /&gt;
We propose now the same problem using the Fourier method. Thus, we seek solutions &amp;lt;math&amp;gt; u (x, t) = \ varphi (x) T (t) &amp;lt;/math&amp;gt; form, where &amp;lt;math&amp;gt; \ varphi (x) &amp;lt;/math&amp;gt; must satisfy the following problem eigenvalue&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{cases}&lt;br /&gt;
\varphi’’(x)+\lambda\varphi(x)=0\\&lt;br /&gt;
\varphi(0)=0, \varphi’(3)=0&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The solution of the differential equation is &amp;lt;math&amp;gt;\varphi(x)=a\cos(\sqrt{\lambda}x)+b\sin(\sqrt{\lambda}x)&amp;lt;/math&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Applying the boundary conditions we obtain the eigenvalues &amp;lt;math&amp;gt;\mu_k&amp;lt;/math&amp;gt; and eigenfunctions &amp;lt;math&amp;gt;\varphi_k(x)&amp;lt;/math&amp;gt; of the problem&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\varphi(0)=0 \rightarrow a=0&amp;lt;/math&amp;gt;;&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\varphi’(3)=0 \rightarrow \sqrt{\lambda}\,b\cos(\sqrt{\lambda}\,3)=0 \rightarrow \sqrt{\lambda}\,3=(k-{1\over2})\,\pi \rightarrow &amp;lt;/math&amp;gt; $\boxed{\lambda=\mu_k=(k-{1\over2})^2{\pi^2\over9}}$;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;Así $\boxed{\varphi_k(x)=\sin(k-{1\over2}){\pi\over3}x}$, &amp;lt;math&amp;gt; \qquad k=1,2,3…N&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If we apply that &amp;lt;math&amp;gt; u_k (x, t) = \ varphi_k (x) T_k (t) &amp;lt;/ math&amp;gt; satisfies the differential equation&amp;lt;math&amp;gt;  u_t-u {xx} = 0 &amp;lt;/ math&amp;gt;, we obtain the differential equation determines &amp;lt;math&amp;gt;T_k(t)&amp;lt;/math&amp;gt;&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;u_t-u{xx}=0 \rightarrow \varphi_k(x)T_k’(t)-\varphi_k’’(x)T_k(t)=\varphi_k(x)T_k’(t)-(-\mu_k)\varphi_k(x)T_k(t)=0 \rightarrow &amp;lt;/math&amp;gt; $\boxed{T_k’(t)+\mu_kT_k(t)=0}$&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The solution of this differential equation $\boxed{T_k(t)=C_ke^{-\mu_kt}= C_ke^{-(k-{1\over2})^2{\pi^2\over9}t}}$ and therefore &amp;lt;math&amp;gt;u_k(x,t)= \varphi_k(x)T_k(t)=C_ke^{-(k-{1\over2})^2{\pi^2\over9}t}\sin(k-{1\over2}){\pi\over3}x&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If we express the solution of the problem as $ \ boxed {u (x, t) = \sum_ {k = 1} ^ Nu_k (x, t) = \sum_ {k = 1} ^ N ^ C_ke {- (k-{1 \over2}) ^ 2 {\pi ^ 2 \over9} t} \sin (k-{1 \over2}) {\pi \over3} x} $ and make satisfying the initial condition we obtain &amp;lt;math&amp;gt;u(x,0)=\sum_{k=1}^NC_k\sin(k-{1\over2}){\pi\over3}x&amp;lt;/math&amp;gt;. Thus, by uniqueness of the Fourier coefficients, the coefficients &amp;lt;math&amp;gt; C_K &amp;lt;/math&amp;gt; match those of the Fourier series with respect to the eigenfunctions &amp;lt;math&amp;gt; \varphi_k (x) &amp;lt;/math&amp;gt; Function apart that determines the initial condition (expressed at the beginning of the article).&lt;br /&gt;
&lt;br /&gt;
The problem is thus limited to the calculation of these coefficients according to the expression&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;$\boxed{C_k={\int_{0}^{3}u(x,0)\varphi_k(x)dx\over\int_{0}^{3}\varphi_k^2(x)dx}}$&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The degree of accuracy of the approximation with this method depends on the number of elements in the Fourier series, ie, the value of &amp;lt;math&amp;gt; N &amp;lt;/math&amp;gt;. We study the temperature of the rod taking &amp;lt;math&amp;gt;  N = 1,3,5,10,20 &amp;lt;/math&amp;gt; values, as you can see in the picture below. It can be seen, especially in the initial condition, that as the value of &amp;lt;math&amp;gt; N &amp;lt;/math&amp;gt; is the approximate increase function is closer to the real.&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo:Untitled4.jpg|thumb|750px|left|Solutions with different number of terms of the Fourier series]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
These results can be better taking a compare &amp;lt;math&amp;gt;  t = 0.5 &amp;lt;/math&amp;gt; fixed instant, and representing each function it in the same graph, as we see below. For this case we also added the approximation with 2 terms of the Fourier series to reflect that up to 3 terms approaches can be distinguished, but once this number of elements in the series approximations are virtually indistinguishable when compared on the same graph.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[Archivo:Untitled3.jpg|thumb|750px|left|Graph of temperature in t=0.5 with N terms of the Fourier series]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The following Matlab code which approximates the temperature of the rod by the Fourier method, with N = 1,3,5,10,20 terms of the series, and step size is reflected&amp;lt;math&amp;gt;h=0,1&amp;lt;/math&amp;gt; in time and space, and &amp;lt;math&amp;gt;t \in \mbox{[0,10]}&amp;lt;/math&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
clear all&lt;br /&gt;
%Seventh section of the paper&lt;br /&gt;
% solve the heat equation ut-uxx = 0 with&lt;br /&gt;
% U (0, t) = 0 ux (L, t) = 0 u (x, 0) = the function piecewise title&lt;br /&gt;
% Resolution with fourier&lt;br /&gt;
L=3;T=10;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=hx;&lt;br /&gt;
x=0:hx:L;t=0:ht:T;&lt;br /&gt;
[xx,tt]=meshgrid(x,t);&lt;br /&gt;
q=[1,2,3,5,10,20];&lt;br /&gt;
a=[1,3,5,10,20];&lt;br /&gt;
f=10*x/3;f(11:21)=100;&lt;br /&gt;
i=0;&lt;br /&gt;
for Q=q&lt;br /&gt;
u=0;&lt;br /&gt;
for k=1:Q&lt;br /&gt;
    p=sin((k-1/2)*(pi/3)*x);&lt;br /&gt;
    c=trapz(x,f.*p)/trapz(x,p.*p);&lt;br /&gt;
    u=u+c*exp(-((k-1/2)^2)*((pi/3)^2)*tt).*sin((k-1/2)*(pi/3)*xx);&lt;br /&gt;
end&lt;br /&gt;
b=find(Q==a);&lt;br /&gt;
if b&amp;lt;6&lt;br /&gt;
i=i+1;&lt;br /&gt;
figure(1)&lt;br /&gt;
subplot(2,3,i)&lt;br /&gt;
ca=num2str(Q);r=strcat(['Solution with ',ca,' terms of the Fourier series']);&lt;br /&gt;
if Q==1&lt;br /&gt;
r=strcat(['Solution with ',ca,' term of the Fourier series']);&lt;br /&gt;
end&lt;br /&gt;
surf(xx,tt,u),xlabel('Space'),ylabel('Time'),zlabel('Temperature'),title(r)&lt;br /&gt;
end&lt;br /&gt;
d(find(q==Q),:)=u(0.5/ht+1,:);&lt;br /&gt;
end&lt;br /&gt;
figure(2)&lt;br /&gt;
hold on&lt;br /&gt;
title('Temperature in t=0.5 with N terms of the Fourier series')&lt;br /&gt;
plot(x,d(1:6,:))&lt;br /&gt;
xlabel('Space'),ylabel('Time')&lt;br /&gt;
legend('N=1','N=2','N=3','N=5','N=10','N=20','Location','best')&lt;br /&gt;
hold off&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Losses along the rod=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now we will study the case where there are heat sources or sinks along the rod. Specifically, if there is heat loss through the air having a constant temperature of 16 degrees. With the boundary conditions that we had initially keeping the left and right at 0 and 10 degrees respectively ends, the problem would be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{cases}&lt;br /&gt;
u_t-u_{xx}+u-16=0,\ x \in \mbox{[0,3]} &amp;amp;  t&amp;gt;0 \\&lt;br /&gt;
u(0,t)=0; u(3,t)=10; &amp;amp; u(x,0)=g(x) ;&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;math&amp;gt;g(x)&amp;lt;/math&amp;gt;  is defined as in the first problem:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
u_0=&lt;br /&gt;
\begin{cases}&lt;br /&gt;
10x/3 &amp;amp;  \mbox{si}  &amp;amp;  x \in \mbox{(0,1)} \cup \mbox{(2,3)}   \\&lt;br /&gt;
100     &amp;amp;  \mbox{si}  &amp;amp;   x \in \mbox{(1,2)}   &lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To solve the problem by finite differences with a term in &amp;lt;math&amp;gt; u (x, t) &amp;lt;/math&amp;gt; need to rethink the discretization in space:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{cases}&lt;br /&gt;
u’_n(t)+\frac{-u_{n-1}(t)+2u_n(t)-u_{n+1}(t)}{h^2}+u_n(t)=16&amp;amp;n=1,2,…,N&amp;amp;t&amp;gt;0 \\&lt;br /&gt;
u_0(t)=0 \\&lt;br /&gt;
u_N(t)=10 \\&lt;br /&gt;
u_n(0)=g(x)&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus, the resulting matrices are as follows&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
K=&lt;br /&gt;
\begin{pmatrix}&lt;br /&gt;
 2 &amp;amp; -1 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp; 0 &amp;amp; 0 \\&lt;br /&gt;
 -1 &amp;amp; 2 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp;0 &amp;amp; 0 \\&lt;br /&gt;
 … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … \\&lt;br /&gt;
 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp; -1 &amp;amp; 2 &lt;br /&gt;
\end{pmatrix}&lt;br /&gt;
\frac{1}{h^2}+&lt;br /&gt;
\begin{pmatrix} &lt;br /&gt;
1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp; 0 &amp;amp; 0 \\&lt;br /&gt;
0 &amp;amp; 1 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp;0 &amp;amp; 0 \\&lt;br /&gt;
… &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … \\&lt;br /&gt;
0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp; 0 &amp;amp; 1&lt;br /&gt;
\end{pmatrix}&lt;br /&gt;
&amp;lt;/math&amp;gt;; &amp;lt;math&amp;gt;&lt;br /&gt;
F=&lt;br /&gt;
\begin{pmatrix}&lt;br /&gt;
16+\frac{0}{h^2} \\&lt;br /&gt;
16 \\&lt;br /&gt;
… \\&lt;br /&gt;
16+\frac{10}{h^2} \\&lt;br /&gt;
\end{pmatrix}&lt;br /&gt;
&amp;lt;/math&amp;gt;; &amp;lt;math&amp;gt;&lt;br /&gt;
U=&lt;br /&gt;
\begin{pmatrix}&lt;br /&gt;
u_1 \\&lt;br /&gt;
u_2 \\&lt;br /&gt;
… \\&lt;br /&gt;
u_{N-1} \\&lt;br /&gt;
\end{pmatrix}&lt;br /&gt;
&amp;lt;/math&amp;gt;; &amp;lt;math&amp;gt;&lt;br /&gt;
U^0=&lt;br /&gt;
\begin{pmatrix}&lt;br /&gt;
g(x_1) \\&lt;br /&gt;
g(x_2) \\&lt;br /&gt;
… \\&lt;br /&gt;
g(x_{N-1})&lt;br /&gt;
\end{pmatrix}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this we can move to numerically solve the problem, but we must recalculate the steady state of the despising rod &amp;lt;math&amp;gt;u_t(x,t)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;u_t(x,t)\approx 0; \ u_{xx}-u+16=0; \ u(0)=0 \ u(3)=10&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is nothing more than an ordinary differential equation of 2nd order with constant coefficients, whose solution is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;a(t)e^x+b(t)e^{-x}+16&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;math&amp;gt; a (t) &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; b (t) &amp;lt;/math&amp;gt; are constants to be obtained to replace and solve the system with the boundary conditions, which in our case have let him Matlab resolved (see lines 22 and 23 of the code).&lt;br /&gt;
Now, we turn to numerically solve the problem, with &amp;lt;math&amp;gt;h=0,1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;t \in \mbox{[0,10]}&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
clear all&lt;br /&gt;
%solve the heat equation ut-uxx + u-16 = 0 with&lt;br /&gt;
% U (0, t) = 0 u (l, t) = 10 u (x, 0) = the function to set pieces&lt;br /&gt;
L=3;T=10;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=hx;&lt;br /&gt;
K=(2*diag(ones(1,Nx-1))-diag(ones(1,Nx-2),1)-diag(ones(1,Nx-2),-1))/(hx^2);&lt;br /&gt;
K=K+eye(Nx-1);&lt;br /&gt;
x=hx:hx:L-hx;&lt;br /&gt;
F=16*ones(Nx-1,1);F(Nx-1)=16+10/(hx^2);&lt;br /&gt;
t=0:ht:T;&lt;br /&gt;
u0=10*x/3;u0(10:20)=100;&lt;br /&gt;
uu=u0';&lt;br /&gt;
U(1,:)=[0 u0 10];&lt;br /&gt;
%metoodo de Euler implicito&lt;br /&gt;
for n=1:(length(t)-1)&lt;br /&gt;
 uu=(eye(Nx-1)+(ht)*K)\(uu+ht*F);&lt;br /&gt;
 U(n+1,:)=[0 uu' 10];&lt;br /&gt;
end&lt;br /&gt;
X=0:hx:L;&lt;br /&gt;
[xx,tt]=meshgrid(X,t);&lt;br /&gt;
a=[1 1;exp(3) exp(-3)];b=[-16;-6];d=a\b;&lt;br /&gt;
V=d(1)*exp(xx)+d(2)*exp(-xx)+16*ones(T/ht+1,Nx+1);&lt;br /&gt;
figure(1)&lt;br /&gt;
hold on&lt;br /&gt;
surf(xx,tt,U)&lt;br /&gt;
xlabel('space')&lt;br /&gt;
ylabel('time')&lt;br /&gt;
zlabel('temperature')&lt;br /&gt;
h1=surf(xx,tt,V),set(h1,'FaceColor','red','FaceAlpha',0.5,'EdgeColor','w')&lt;br /&gt;
xlabel('space')&lt;br /&gt;
ylabel('time')&lt;br /&gt;
zlabel('temperature')&lt;br /&gt;
E=abs(U-V);&lt;br /&gt;
e1=E(46:101,Nx/6+1);&lt;br /&gt;
e2=E(46:101,Nx/3+1);&lt;br /&gt;
e3=E(46:101,Nx/2+1);&lt;br /&gt;
e4=E(46:101,2*Nx/3+1);&lt;br /&gt;
e5=E(46:101,5*Nx/6+1);&lt;br /&gt;
figure(3)&lt;br /&gt;
hold on&lt;br /&gt;
plot(t(46:101),e1)&lt;br /&gt;
plot(t(46:101),e2,'r')&lt;br /&gt;
plot(t(46:101),e3,'k')&lt;br /&gt;
plot(t(46:101),e4,'m')&lt;br /&gt;
plot(t(46:101),e5,'c'),legend('Difference in x=0.5','Difference in x=1',...&lt;br /&gt;
'Difference in x=1.5','Difference in x=2','Difference in x=2.5')&lt;br /&gt;
plot(t(46:101),0.001*ones(1,length(t)-45),'g'),xlabel('time'),...&lt;br /&gt;
ylabel('Difference with the stationary solution')&lt;br /&gt;
hold off&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo:Untitled002.jpg|thumb|750px|left|Graph of &amp;lt;math&amp;gt;u(x,t)&amp;lt;/math&amp;gt;  in &amp;lt;math&amp;gt;x \in \mbox{[0,3]};t \in \mbox{[0,10]}&amp;lt;/math&amp;gt;. In pink is the stationary solution. ]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
As shown in the graph, the actual solution and stationary are virtually identical for &amp;lt;math&amp;gt;  t&amp;gt; 2 &amp;lt;/math&amp;gt;. Furthermore we see that near &amp;lt;math&amp;gt; t = 5 &amp;lt;/math&amp;gt; the stationary solution is above the real solution. This is best seen in the following graph in which are represented the difference between the actual solution and the stationary for different values of &amp;lt;math&amp;gt;  x &amp;lt;/math&amp;gt;, namely &amp;lt;math&amp;gt;x = 0.5,1,1.5,2,2.5  &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo:Untitled01.jpg|thumb|750px|left|Graph with the difference between the real and the stationary solution for&amp;lt;math&amp;gt;t \in \mbox{[4.5,10]}&amp;lt;/math&amp;gt; ]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
At that point cut the difference between the two is minimal, below &amp;lt;math&amp;gt; 10 ^ {-3 } &amp;lt;/math&amp;gt;, while from there this difference increases slightly and remained constant when time is increasing. This was expected, since for large times the solution of the equation is stationary, and therefore effects of time we have is the difference between two constants. The existing small difference between the two may be because logically, does not disclose exact thing but we are solving the equation numerically.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Changing the boundary conditions==&lt;br /&gt;
&lt;br /&gt;
Suppose now that we change the boundary conditions, so that now the left end of the rod to be in contact with a material whose temperature varies according to the function &amp;lt;math&amp;gt; 10sen (t) &amp;lt;/math&amp;gt;, and by the end right there is a flow of constant heat input &amp;lt;math&amp;gt; 1 &amp;lt;/math&amp;gt;. These conditions translate as &amp;lt;math&amp;gt; u (0, t) = 10sen (t) &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; u_x (3, t) = 1 &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
As the second condition of Neumann type, size of the matrices increases one unit, to be known &amp;lt;math&amp;gt; u_n &amp;lt;/math&amp;gt; term. Also &amp;lt;math&amp;gt; K &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; F &amp;lt;/math&amp;gt; change their terms, becoming&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
K=&lt;br /&gt;
\begin{pmatrix}&lt;br /&gt;
 2 &amp;amp; -1 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp; 0 &amp;amp; 0 \\&lt;br /&gt;
 -1 &amp;amp; 2 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp;0 &amp;amp; 0 \\&lt;br /&gt;
 … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … \\&lt;br /&gt;
 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp; -2 &amp;amp; 2 &lt;br /&gt;
\end{pmatrix}&lt;br /&gt;
\frac{1}{h^2}+&lt;br /&gt;
\begin{pmatrix} &lt;br /&gt;
1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp; 0 &amp;amp; 0 \\&lt;br /&gt;
0 &amp;amp; 1 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp;0 &amp;amp; 0 \\&lt;br /&gt;
… &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … &amp;amp; … \\&lt;br /&gt;
0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; … &amp;amp; 0 &amp;amp; 1&lt;br /&gt;
\end{pmatrix}&lt;br /&gt;
&amp;lt;/math&amp;gt;; &amp;lt;math&amp;gt;&lt;br /&gt;
F=&lt;br /&gt;
\begin{pmatrix}&lt;br /&gt;
16+\frac{10sen(t_n)}{h^2} \\&lt;br /&gt;
16 \\&lt;br /&gt;
… \\&lt;br /&gt;
16+\frac{2}{h} \\&lt;br /&gt;
\end{pmatrix}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We solve the implicit Euler method with &amp;lt;math&amp;gt;h=0,1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;t \in \mbox{[0,10]}&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
clear all&lt;br /&gt;
%solve the heat equation ut-uxx + u-16 = 0 with&lt;br /&gt;
% U (0, t) = 10 * sin (t) ux (L, t) = 1 u (x, 0) = the function piecewise title&lt;br /&gt;
L=3;T=10;&lt;br /&gt;
Nx=30;hx=L/Nx;&lt;br /&gt;
ht=hx;&lt;br /&gt;
K=(2*diag(ones(1,Nx))-diag(ones(1,Nx-1),1)-diag(ones(1,Nx-1),-1));K(Nx,Nx-1)=-2;K=K/(hx^2);&lt;br /&gt;
K=K+eye(Nx);&lt;br /&gt;
x=hx:hx:L;&lt;br /&gt;
t=0:ht:T;&lt;br /&gt;
u0=10*x/3;u0(10:20)=100;&lt;br /&gt;
uu=u0';&lt;br /&gt;
g=10*sin(t);&lt;br /&gt;
U(1,:)=[g(1) u0];&lt;br /&gt;
%implicit Euler method&lt;br /&gt;
for n=1:(length(t)-1)&lt;br /&gt;
   F=16*ones(Nx,1);F(Nx)=16+2/hx;F(1)=16+g(n)/(hx^2);&lt;br /&gt;
   uu=(eye(Nx)+(ht)*K)\(uu+ht*F);&lt;br /&gt;
   U(n+1,:)=[g(n+1) uu'];&lt;br /&gt;
end&lt;br /&gt;
X=0:hx:L;&lt;br /&gt;
[xx,tt]=meshgrid(X,t);&lt;br /&gt;
figure(1)&lt;br /&gt;
surf(xx,tt,U)&lt;br /&gt;
xlabel('space')&lt;br /&gt;
ylabel('time')&lt;br /&gt;
zlabel('Temperature')&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo:untitled.jpg|thumb|750px|left|Graph of &amp;lt;math&amp;gt;u(x,t)&amp;lt;/math&amp;gt;  in &amp;lt;math&amp;gt;x \in \mbox{[0,3]};t \in \mbox{[0,10]}&amp;lt;/math&amp;gt; ]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In view of the graph we can conclude that as previously when we had a Neumann type condition, the heat &amp;quot;escapes&amp;quot; from the left end at a variable temperature with time while entering from the right. This can be seen if the program is run on the graph by observing the slight slope that the surface of temperatures has at the left side.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Categoría:Ecuaciones Diferenciales]]&lt;br /&gt;
[[Categoría:ED13/14]]&lt;br /&gt;
[[Categoría:Trabajos 2013-14]]&lt;/div&gt;</summary>
		<author><name>Marino Rivera</name></author>	</entry>

	<entry>
		<id>https://mat.caminos.upm.es/w/index.php?title=Archivo:AP7a.png&amp;diff=11272</id>
		<title>Archivo:AP7a.png</title>
		<link rel="alternate" type="text/html" href="https://mat.caminos.upm.es/w/index.php?title=Archivo:AP7a.png&amp;diff=11272"/>
				<updated>2014-05-15T10:11:43Z</updated>
		
		<summary type="html">&lt;p&gt;Marino Rivera: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Marino Rivera</name></author>	</entry>

	<entry>
		<id>https://mat.caminos.upm.es/w/index.php?title=Archivo:AP7b.png&amp;diff=11271</id>
		<title>Archivo:AP7b.png</title>
		<link rel="alternate" type="text/html" href="https://mat.caminos.upm.es/w/index.php?title=Archivo:AP7b.png&amp;diff=11271"/>
				<updated>2014-05-15T10:02:11Z</updated>
		
		<summary type="html">&lt;p&gt;Marino Rivera: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Marino Rivera</name></author>	</entry>

	<entry>
		<id>https://mat.caminos.upm.es/w/index.php?title=Archivo:AP6a.png&amp;diff=11270</id>
		<title>Archivo:AP6a.png</title>
		<link rel="alternate" type="text/html" href="https://mat.caminos.upm.es/w/index.php?title=Archivo:AP6a.png&amp;diff=11270"/>
				<updated>2014-05-15T10:01:39Z</updated>
		
		<summary type="html">&lt;p&gt;Marino Rivera: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Marino Rivera</name></author>	</entry>

	<entry>
		<id>https://mat.caminos.upm.es/w/index.php?title=Archivo:AP7A.png&amp;diff=11269</id>
		<title>Archivo:AP7A.png</title>
		<link rel="alternate" type="text/html" href="https://mat.caminos.upm.es/w/index.php?title=Archivo:AP7A.png&amp;diff=11269"/>
				<updated>2014-05-15T09:53:04Z</updated>
		
		<summary type="html">&lt;p&gt;Marino Rivera: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Marino Rivera</name></author>	</entry>

	<entry>
		<id>https://mat.caminos.upm.es/w/index.php?title=Archivo:AP6A.png&amp;diff=11268</id>
		<title>Archivo:AP6A.png</title>
		<link rel="alternate" type="text/html" href="https://mat.caminos.upm.es/w/index.php?title=Archivo:AP6A.png&amp;diff=11268"/>
				<updated>2014-05-15T09:52:49Z</updated>
		
		<summary type="html">&lt;p&gt;Marino Rivera: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Marino Rivera</name></author>	</entry>

	<entry>
		<id>https://mat.caminos.upm.es/w/index.php?title=Archivo:AP7B.png&amp;diff=11267</id>
		<title>Archivo:AP7B.png</title>
		<link rel="alternate" type="text/html" href="https://mat.caminos.upm.es/w/index.php?title=Archivo:AP7B.png&amp;diff=11267"/>
				<updated>2014-05-15T09:51:05Z</updated>
		
		<summary type="html">&lt;p&gt;Marino Rivera: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Marino Rivera</name></author>	</entry>

	<entry>
		<id>https://mat.caminos.upm.es/w/index.php?title=Archivo:AP6A.jpg&amp;diff=11266</id>
		<title>Archivo:AP6A.jpg</title>
		<link rel="alternate" type="text/html" href="https://mat.caminos.upm.es/w/index.php?title=Archivo:AP6A.jpg&amp;diff=11266"/>
				<updated>2014-05-15T09:48:52Z</updated>
		
		<summary type="html">&lt;p&gt;Marino Rivera: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Marino Rivera</name></author>	</entry>

	<entry>
		<id>https://mat.caminos.upm.es/w/index.php?title=Boundary_layer_in_laminar_fluids_(Grupo_1B)&amp;diff=10752</id>
		<title>Boundary layer in laminar fluids (Grupo 1B)</title>
		<link rel="alternate" type="text/html" href="https://mat.caminos.upm.es/w/index.php?title=Boundary_layer_in_laminar_fluids_(Grupo_1B)&amp;diff=10752"/>
				<updated>2014-05-01T18:06:07Z</updated>
		
		<summary type="html">&lt;p&gt;Marino Rivera: Deshecha la revisión 10751 de Marino Rivera (disc.)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ TrabajoED |Boundary layer in laminar fluids. Grupo 1-B | [[:Categoría:Ecuaciones Diferenciales|Ecuaciones Diferenciales]]|[[:Categoría:ED13/14|Curso 2013-14]] | Sandro Andrés Martínez &lt;br /&gt;
 &lt;br /&gt;
David Ayala Díez &lt;br /&gt;
 &lt;br /&gt;
Claudia Cózar Coarasa  &lt;br /&gt;
&lt;br /&gt;
Lorena de la Fuente Sanz  &lt;br /&gt;
&lt;br /&gt;
Marino Rivera Muñoz &lt;br /&gt;
  &lt;br /&gt;
José Manuel Torres Serrano }}&lt;br /&gt;
&lt;br /&gt;
In this numerical project we have studied what happens when we introduce a flat plate in a laminar fluid whose speed and viscosity are constant.&lt;br /&gt;
&lt;br /&gt;
= Blasius equation =	&lt;br /&gt;
&lt;br /&gt;
First, we must assume that the fluid velocity before reaching the plate is constant, as in remote areas after passing the plate.&lt;br /&gt;
&lt;br /&gt;
In our case we take this constant as &amp;lt;math&amp;gt;2&amp;lt;/math&amp;gt;, such that&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\overrightarrow{u} =  u_0\cdot\overrightarrow{i}, u_0 = 2 &amp;lt;/math&amp;gt;&lt;br /&gt;
[[Archivo:Flujo.png|thumb|200px|left|Laminar fluid with velocity &amp;lt;math&amp;gt; u_0 &amp;lt;/math&amp;gt;]]&lt;br /&gt;
&lt;br /&gt;
Then, we must define the fluid stream function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\psi(x,y)  =  \sqrt[]{ \nu \cdot\ u_0 \cdot x} f(\eta)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where we take the viscosity &amp;lt;math&amp;gt; \nu &amp;lt;/math&amp;gt; as a unit value and&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\eta  = y  \sqrt[]{ \frac{u_0}{\nu x}}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt; f(\eta) &amp;lt;/math&amp;gt; Satisfies the Blasius equation, and therefore we will raise the initial value problem associated with this equation with the following initial conditions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{cases}&lt;br /&gt;
f’’’(\eta)+\frac{1}{2}f(\eta)f’’(\eta)=0 ; \\&lt;br /&gt;
f(0)=f’(0)=0, \lim_{\eta \to \infty}f’(\eta)= 1 ;&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
However, on time of programming we cannot introduce a conditional limit, so we have to replace them by the condition &amp;lt;math&amp;gt; f’’(0)=k &amp;lt;/math&amp;gt;, and vary the values of k to find the one that satisfies the limit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We cannot solve the differential equation like such, to apply the numerical methods, we need to pass it to a system of equations:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
f(\eta)=y_1,f’(\eta)=y_2,f’’(\eta)=y_3\\&lt;br /&gt;
\begin{cases}&lt;br /&gt;
y_1’=y_2;\\&lt;br /&gt;
y_2’=y_3;\\&lt;br /&gt;
y_3’=-\frac{1}{2}y_1y_3;\\&lt;br /&gt;
y_1(0)=y_2(0)=0; y_3(0)=k&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once the system has been formulated , we start to solve it.&lt;br /&gt;
&lt;br /&gt;
== Resolution with the modified Euler method ==&lt;br /&gt;
Then is exposed the Matlab code that numerically that solves the Blasius equation for different values of &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; , with &amp;lt;math&amp;gt; k \in \mbox{(0,1;1)}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;dk=0,01&amp;lt;/math&amp;gt;   ,with &amp;lt;math&amp;gt; \eta \in \mbox{(0,20)}&amp;lt;/math&amp;gt; and with &amp;lt;math&amp;gt;h=0,05&amp;lt;/math&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
%Resolution of Blasius equation(with modified Euler)&lt;br /&gt;
clear all&lt;br /&gt;
%Initial conditions&lt;br /&gt;
t0=0;&lt;br /&gt;
tN=20;&lt;br /&gt;
h=0.05;&lt;br /&gt;
N=(tN-t0)/h;&lt;br /&gt;
F2=zeros(91,401);%We create the matrix F2 where we will store the different&lt;br /&gt;
%solutions of f2 for each value of k&lt;br /&gt;
for k=0.1:0.01:1&lt;br /&gt;
y=[0;0;k];&lt;br /&gt;
y1=y(1);&lt;br /&gt;
y2=y(2);&lt;br /&gt;
y3=y(3);&lt;br /&gt;
for n=1:N&lt;br /&gt;
    A=[0 1 0;0 0 1;(-y(3)/2) 0 0]; %To simplify and solve using matrices, we create&lt;br /&gt;
 %the matrix A in the loop with different values of f3&lt;br /&gt;
    z=y+h*A*y;&lt;br /&gt;
    y=y+(h/2)*(A*y+A*z);&lt;br /&gt;
    y1(n+1)=y(1);&lt;br /&gt;
    y2(n+1)=y(2);&lt;br /&gt;
    y3(n+1)=y(3);&lt;br /&gt;
end&lt;br /&gt;
t=[t0:h:tN];&lt;br /&gt;
num=int8(100*(k-0.1+0.01));&lt;br /&gt;
%F2 has as rows approximations of y2 for the different values of k&lt;br /&gt;
F2(num,:)=y2;&lt;br /&gt;
end&lt;br /&gt;
k1=[0.1:0.01:1]; %Vector to represent the values of f2 in 20&lt;br /&gt;
f20=F2(:,401);&lt;br /&gt;
f20=f20';&lt;br /&gt;
o=ones(1,91);%We represented f = 1 for better viewing&lt;br /&gt;
figure(1)&lt;br /&gt;
hold on&lt;br /&gt;
plot(k1,f20,'+')&lt;br /&gt;
plot(k1,o,'r') &lt;br /&gt;
xlabel('k')&lt;br /&gt;
ylabel('f´(20)')&lt;br /&gt;
legend('f´(20)','y=1')&lt;br /&gt;
hold off&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo:Graficaf'(20)M.jpg|thumb|500px|left|Graph of &amp;lt;math&amp;gt;f’(20)&amp;lt;/math&amp;gt;  for each &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; ]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
As noted in the graph the value for which the function is closer to &amp;lt;math&amp;gt;1&amp;lt;/math&amp;gt; is &amp;lt;math&amp;gt;k=0,33&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Resolution with 4th order Runge-Kutta method==&lt;br /&gt;
Then is exposed the Matlab code that numerically that solves the Blasius equation for different values of &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; , with &amp;lt;math&amp;gt; k \in \mbox{(0,1;1)}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;dk=0,01&amp;lt;/math&amp;gt;   ,with &amp;lt;math&amp;gt; \eta \in \mbox{(0,20)}&amp;lt;/math&amp;gt; and with &amp;lt;math&amp;gt;h=0,05&amp;lt;/math&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
% Resolution of Blasius  equation(with Runge-Kutta)&lt;br /&gt;
clear all&lt;br /&gt;
t0=0;&lt;br /&gt;
tN=20;&lt;br /&gt;
h=0.05;&lt;br /&gt;
N=(tN-t0)/h;&lt;br /&gt;
F2=zeros(91,401);&lt;br /&gt;
for k=0.1:0.01:1&lt;br /&gt;
y=[0;0;k];&lt;br /&gt;
y1=y(1);&lt;br /&gt;
y2=y(2);&lt;br /&gt;
y3=y(3);&lt;br /&gt;
for n=1:N&lt;br /&gt;
    A=[0 1 0;0 0 1;(-y(3)/2) 0 0];&lt;br /&gt;
    k1=A*y;&lt;br /&gt;
    k2=A*(y+(h/2)*k1);&lt;br /&gt;
    k3=A*(y+(h/2)*k2);&lt;br /&gt;
    k4=A*(y+h*k3);&lt;br /&gt;
    y=y+(h/6)*(k1+2*k2+2*k3+k4);&lt;br /&gt;
    y1(n+1)=y(1);&lt;br /&gt;
    y2(n+1)=y(2);&lt;br /&gt;
    y3(n+1)=y(3);&lt;br /&gt;
end&lt;br /&gt;
t=[t0:h:tN];&lt;br /&gt;
num=int8(100*(k-0.1+0.01));&lt;br /&gt;
%F2 has as rows approximations of y2 for the different values of k &lt;br /&gt;
F2(num,:)=y2;&lt;br /&gt;
end&lt;br /&gt;
t=[t0:h:tN];&lt;br /&gt;
k1=[0.1:0.01:1];&lt;br /&gt;
f20=F2(:,401);&lt;br /&gt;
f20=f20';&lt;br /&gt;
o=ones(1,91);&lt;br /&gt;
figure(1)&lt;br /&gt;
hold on&lt;br /&gt;
plot(k1,f20,'+')&lt;br /&gt;
plot(k1,o,'r')&lt;br /&gt;
xlabel('k')&lt;br /&gt;
ylabel('f´(20)')&lt;br /&gt;
legend('f´(20)','y=1')&lt;br /&gt;
hold off&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[Archivo: Graficaf'(20)RK.jpg|thumb|500px|left|Graph of &amp;lt;math&amp;gt;f’(20)&amp;lt;/math&amp;gt;  for each &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Resolution with Euler method==&lt;br /&gt;
Then is exposed the Matlab code that numerically that solves the Blasius equation for different values of &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; , with &amp;lt;math&amp;gt; k \in \mbox{(0,1;1)}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;dk=0,01&amp;lt;/math&amp;gt;   ,with &amp;lt;math&amp;gt; \eta \in \mbox{(0,20)}&amp;lt;/math&amp;gt; and with &amp;lt;math&amp;gt;h=0,05&amp;lt;/math&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
%Resolution of Blasius  equation(with Euler)&lt;br /&gt;
&lt;br /&gt;
clear all&lt;br /&gt;
t0=0;&lt;br /&gt;
tN=20;&lt;br /&gt;
h=0.05;&lt;br /&gt;
N=(tN-t0)/h;&lt;br /&gt;
F2=zeros(91,401);&lt;br /&gt;
for k=0.1:0.01:1&lt;br /&gt;
y=[0;0;k];&lt;br /&gt;
y1=y(1);&lt;br /&gt;
y2=y(2);&lt;br /&gt;
y3=y(3);&lt;br /&gt;
for n=1:N&lt;br /&gt;
    A=[0 1 0;0 0 1;(-y(3)/2) 0 0];&lt;br /&gt;
    y=y+h*A*y;&lt;br /&gt;
    y1(n+1)=y(1);&lt;br /&gt;
    y2(n+1)=y(2);&lt;br /&gt;
    y3(n+1)=y(3);&lt;br /&gt;
end&lt;br /&gt;
t=[t0:h:tN];&lt;br /&gt;
num=int8(100*(k-0.1+0.01));&lt;br /&gt;
%F2 has as rows approximations of y2 for the different values of k &lt;br /&gt;
F2(num,:)=y2;&lt;br /&gt;
end&lt;br /&gt;
t=[t0:h:tN];&lt;br /&gt;
k1=[0.1:0.01:1];&lt;br /&gt;
f20=F2(:,401);&lt;br /&gt;
f20=f20';&lt;br /&gt;
o=ones(1,91);&lt;br /&gt;
figure(1)&lt;br /&gt;
hold on&lt;br /&gt;
plot(k1,f20,'+')&lt;br /&gt;
plot(k1,o,'r')&lt;br /&gt;
xlabel('k')&lt;br /&gt;
ylabel('f´(20)')&lt;br /&gt;
legend('f´(20)','y=1')&lt;br /&gt;
hold off&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[Archivo: Graficaf'(20).jpg|thumb|500px|left|Graph of &amp;lt;math&amp;gt;f’(20)&amp;lt;/math&amp;gt;  for each &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;]]&lt;br /&gt;
|}&lt;br /&gt;
== Conclusion==&lt;br /&gt;
Comparing the graphs, we see that the difference between modified Euler and 4th order Runge Kutta methods is minimal and the value for each parameter is &amp;lt;math&amp;gt;k=0,33&amp;lt;/math&amp;gt; , on the other hand, by using the Euler method (less accurate than the above) the value of the parameter is &amp;lt;math&amp;gt;k=0,32&amp;lt;/math&amp;gt;, although graphically this difference is hardly seen.&lt;br /&gt;
&lt;br /&gt;
==Graph of &amp;lt;math&amp;gt;f´(\eta)&amp;lt;/math&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The graph of &amp;lt;math&amp;gt;f'(\eta)&amp;lt;/math&amp;gt;has been realized in &amp;lt;math&amp;gt;\eta \in \mbox {(0,20)}&amp;lt;/math&amp;gt; for the value of parameter &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; obtained in the modified Euler method, ie &amp;lt;math&amp;gt;k=0.33&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To get this graph we add into the modified Euler method, the following MATLAB code:&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
&lt;br /&gt;
%We plot f2 for k = 0.33 which is in row 24 of the matrix&lt;br /&gt;
f2=F2(24,:);&lt;br /&gt;
figure(2)&lt;br /&gt;
plot(t,f2,'*')&lt;br /&gt;
xlabel('\eta')&lt;br /&gt;
ylabel('f´(\eta)')&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| [[Archivo: Graficaf'eta.jpg|thumb|800px|left|Graph of &amp;lt;math&amp;gt;f´(\eta)&amp;lt;/math&amp;gt; for &amp;lt;math&amp;gt;k=0,33&amp;lt;/math&amp;gt; ]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As can be seen, if we run the full program and see the vector &amp;lt;math&amp;gt;f2&amp;lt;/math&amp;gt; the value of &amp;lt;math&amp;gt;\eta_0&amp;lt;/math&amp;gt; for which &amp;lt;math&amp;gt;\ \vert f'(\eta)-1 \vert &amp;lt; 0,01&amp;lt;/math&amp;gt; , if &amp;lt;math&amp;gt;\eta&amp;gt;\eta _0&amp;lt;/math&amp;gt;, is &amp;lt;math&amp;gt;\eta_0\ge5,95&amp;lt;/math&amp;gt; for &amp;lt;math&amp;gt; \eta \in \mbox{(0,20)}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Horizontal velocity of the fluid=&lt;br /&gt;
Once we have numerically calculated the &amp;lt;math&amp;gt;f( \eta)&amp;lt;/math&amp;gt; we proceed to calculate the horizontal component of the fluid velocity &amp;lt;math&amp;gt; u_1 &amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\vec{u}=(u_1,u_2)=(\frac{\partial \psi}{\partial y},-\frac{\partial \psi}{\partial x})&amp;lt;/math&amp;gt;  Thus, as defined above:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;u_1=\frac{\partial \psi}{\partial y}=\frac{\partial }{\partial y}(\sqrt[]{\nu u_0 x} f(\eta))= \sqrt[]{\nu u_0 x} \frac{\partial f(\eta)}{\partial y}=\sqrt[]{\nu u_0 x} \frac{\partial f(\eta)}{\partial \eta} \frac{\partial \eta}{\partial y}=\sqrt[]{\nu u_0 x} \sqrt[]{\frac{u_0}{\nu x}} f’(\eta)=u_0 f’(\eta)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To translate this result graphically we calculate &amp;lt;math&amp;gt;u_1(x_k,y)&amp;lt;/math&amp;gt; with the Modified Euler method where &amp;lt;math&amp;gt;x_k=0.05,0.2,0.4,0.6,0.8&amp;lt;/math&amp;gt;  and &amp;lt;math&amp;gt;y \in \mbox{(0,3)}&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;h=0.01&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
%We calculate u1 with the different values of xk(with modified Euler)&lt;br /&gt;
clear all&lt;br /&gt;
xk=[0.05,0.2,0.4,0.6,0.8];&lt;br /&gt;
nu=1; u0=2;&lt;br /&gt;
y0=0; yN=3; hy=0.01;&lt;br /&gt;
N=(yN-y0)/hy;&lt;br /&gt;
y=y0:hy:yN;&lt;br /&gt;
for m=1:5&lt;br /&gt;
%We define eta ('t') for each value of  xk, each one &lt;br /&gt;
%corresponding to a row, and with 'y' in (0,3)&lt;br /&gt;
t(m,:)=sqrt(u0/(nu*xk(m)))*y;&lt;br /&gt;
h=sqrt(u0/(nu*xk(m)))*0.01;&lt;br /&gt;
f0=[0;0;0.33];&lt;br /&gt;
f=[f0(1);f0(2);f0(3)];&lt;br /&gt;
for n=1:N&lt;br /&gt;
    A=[0 1 0;0 0 1;(-f0(3)/2) 0 0];&lt;br /&gt;
    z=f0+h*A*f0;&lt;br /&gt;
    f0=f0+(h/2)*(A*f0+A*z);&lt;br /&gt;
    f(:,n+1)=[f0(1);f0(2);f0(3)];&lt;br /&gt;
end&lt;br /&gt;
Y(m,:)=f(2,:);&lt;br /&gt;
end&lt;br /&gt;
F=u0*Y;&lt;br /&gt;
hold on&lt;br /&gt;
plot(y,F(1,:),'k')&lt;br /&gt;
plot(y,F(2,:))&lt;br /&gt;
plot(y,F(3,:),'r')&lt;br /&gt;
plot(y,F(4,:),'m')&lt;br /&gt;
plot(y,F(5,:),'g')&lt;br /&gt;
legend('u_{1} for x_{k}=0.05','u_{1} for x_{k}=0.2','u_{1} for x_{k}=0.4','u_{1} for x_{k}=0.6','u_{1} for x_{k}=0.8','location','best')&lt;br /&gt;
xlabel('y')&lt;br /&gt;
ylabel('u_{1}')&lt;br /&gt;
hold off&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Archivo:Ap4a.png|thumb|800px|centre|In this picture are shown &amp;lt;math&amp;gt;5&amp;lt;/math&amp;gt; graphs, each one corresponds to a different value of &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;. ]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
According to this graph we can appreciate that the fluid, when is moving along the &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; axis, has to achieve higher height to get limit velocity &amp;lt;math&amp;gt;u_0&amp;lt;/math&amp;gt;, i.e., when the fluid moves, it must be getting over the plate to offset the perturbation that the plate causes to it ( to a higher value of &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; is greater the transition zone between zero velocity of the plate and the limit velocity &amp;lt;math&amp;gt;u_0&amp;lt;/math&amp;gt; with which the fluid initially starts).&lt;br /&gt;
&lt;br /&gt;
= Laminar boundary layer of the fluid =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
According to the above findings, it can be deduced that there is for each value of &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; a limit value  &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; from which the fluid velocity becomes constant speed again, with the same value that it had initially before reaching the area of the plate.&lt;br /&gt;
Obviously the value of the boundary layer will be related to the value &amp;lt;math&amp;gt;\eta_0&amp;lt;/math&amp;gt;, calculated above, for which the function &amp;lt;math&amp;gt;f’(\eta)&amp;lt;/math&amp;gt;  will become almost constant. The relationship is expressed as follows:&lt;br /&gt;
&amp;lt;math&amp;gt;\eta  = y  \sqrt[]{ \frac{u_0}{\nu x}}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;math&amp;gt;\eta=\eta_0&amp;lt;/math&amp;gt;, then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\eta_0=y  \sqrt[]{ \frac{2}{x}};  y=\frac{\eta_0\sqrt[]{x}}{\sqrt[]{2}}=g(x);&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Therefore we can interpret this function &amp;lt;math&amp;gt;g(x)&amp;lt;/math&amp;gt; as the fluid boundary layer. Simple Matlab code is exposed for its representation:&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
%plot function g(x)&lt;br /&gt;
x=[0:0.05:10];&lt;br /&gt;
eta0=5.95;&lt;br /&gt;
y=eta0*(x/2).^(1/2);&lt;br /&gt;
plot(x,y,'r')&lt;br /&gt;
xlabel('x')&lt;br /&gt;
ylabel('g(x)')&lt;br /&gt;
legend('g(x), interpreted as boundary layer','location','best')&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[Archivo: Figureg(x).jpg|thumb|500px|left|Graph of &amp;lt;math&amp;gt;g(x)&amp;lt;/math&amp;gt; ]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In view of the graph, the findings are similar to previous ones. As the value &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; increases, you need a higher value of &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; for the fluid velocity stabilizes and becomes the speed that we had initially.&lt;br /&gt;
&lt;br /&gt;
[[Categoría:Ecuaciones Diferenciales]]&lt;br /&gt;
[[Categoría:ED13/14]]&lt;br /&gt;
[[Categoría:Trabajos 2013-14]]&lt;/div&gt;</summary>
		<author><name>Marino Rivera</name></author>	</entry>

	<entry>
		<id>https://mat.caminos.upm.es/w/index.php?title=Boundary_layer_in_laminar_fluids_(Grupo_1B)&amp;diff=10751</id>
		<title>Boundary layer in laminar fluids (Grupo 1B)</title>
		<link rel="alternate" type="text/html" href="https://mat.caminos.upm.es/w/index.php?title=Boundary_layer_in_laminar_fluids_(Grupo_1B)&amp;diff=10751"/>
				<updated>2014-05-01T18:03:31Z</updated>
		
		<summary type="html">&lt;p&gt;Marino Rivera: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ TrabajoED |Boundary layer in laminar fluids. Grupo 1-B | [[:Categoría:Ecuaciones Diferenciales|Ecuaciones Diferenciales]]|[[:Categoría:ED13/14|Curso 2013-14]] | Sandro Andrés Martínez &lt;br /&gt;
 &lt;br /&gt;
David Ayala Díez &lt;br /&gt;
 &lt;br /&gt;
Claudia Cózar Coarasa  &lt;br /&gt;
&lt;br /&gt;
Lorena de la Fuente Sanz  &lt;br /&gt;
&lt;br /&gt;
Marino Rivera Muñoz &lt;br /&gt;
  &lt;br /&gt;
José Manuel Torres Serrano }}&lt;br /&gt;
&lt;br /&gt;
In this numerical project we have studied what happens when we introduce a flat plate in a laminar fluid whose speed and viscosity are constant.&lt;br /&gt;
&lt;br /&gt;
= Condición de frontera tipo Neumann =&lt;br /&gt;
&lt;br /&gt;
Ahora vamos a considerar una condición de frontera diferente en el extremo derecho. En vez de suponer una temperatura constante en ese extremo como anteriormente, vamos a colocar en él una pieza aislante. Este aislante provoca que no haya pérdida de calor por el extremo derecho, es decir, que el flujo de temperatura sea nulo. Esta condición es de tipo Neumann, a diferencia de las anteriores que eran de tipo Dirichlet. Así, mantenemos la condición en el extremo izquierdo y aplicamos la nueva en el extremo derecho, que resulta&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;-ku_x(3,t)=0 \rightarrow u_x(3,t)=0&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
En esta situación, la temperatura de la varilla viene dada por el siguiente problema&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{cases}&lt;br /&gt;
u_t-u_{xx}=0, \qquad x\epsilon(0,3), t&amp;gt;0\\&lt;br /&gt;
u(0,t)=0; u_x(3,t)=0, \qquad t&amp;gt;0\\&lt;br /&gt;
u(x,0)=u_0(x), \qquad x\epsilon[0,3]&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Por lo tanto, ahora en el estado estacionario para tiempos grandes la función &amp;lt;math&amp;gt;u(x,t)&amp;lt;/math&amp;gt; que modeliza la temperatura de la varilla es solución del siguiente problema de contorno (lo llamamos así pues la ecuación diferencial depende únicamente de &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; en el estado estacionario)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{cases}&lt;br /&gt;
u_{xx}=0, \qquad x\epsilon(0,3), t&amp;gt;0\\&lt;br /&gt;
u(0,t)=0, u_x(3,t)=0, \qquad t&amp;gt;0&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Resolvemos la ecuación diferencial obteniendo el mismo resultado que anteriormente&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;u_{xx}=0 \rightarrow u(x,t)=C_1(t)x+C_2(t)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Aplicando las condiciones de frontera: &amp;lt;math&amp;gt;C_1(t)=C_2(t)=0 \rightarrow u(x,t)=0&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Este resultado refleja que al cabo de un tiempo lo suficientemente grande como para considerar un estado estacionario en la varilla, esta adquiere una temperatura uniforme nula. El comportamiento de la varilla es coherente con las condiciones de frontera, pues la temperatura final de la varilla es la que se mantiene constante en el extremo izquierdo, que permite flujo de temperatura.&lt;br /&gt;
&lt;br /&gt;
==Método de diferencias finitas==&lt;br /&gt;
&lt;br /&gt;
En la siguiente imagen se muestra una aproximación del problema mediante el método de diferencias finitas. En ella se puede apreciar como para un valor elevado del tiempo la temperatura en la varilla se puede considerar constante y uniforme en toda ella, alcanzando el valor estacionario &amp;lt;math&amp;gt;u(x,t)=0&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
(IMAGEN)&lt;br /&gt;
&lt;br /&gt;
En concreto, a partir de un tiempo &amp;lt;math&amp;gt;t=…&amp;lt;/math&amp;gt; podemos considerar que la temperatura alcanza dicho valor estacionario con un error del 5%, es decir, en ese instante la diferencia entre la distribución térmica calculada y la estacionaria es… (ESTA PARTE HAY QUE COMPLETARLA CUANDO PREGUNTEMOS A CARLOS A QUÉ SE REFIERE EL 5%).&lt;br /&gt;
&lt;br /&gt;
A continuación se refleja el código de Matlab que aproxima la temperatura de la varilla por diferencias finitas usando el método de Euler implícito por ser el que aporta una mejor aproximación.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Método de Fourier==&lt;br /&gt;
&lt;br /&gt;
Planteamos ahora el mismo problema usando el método de Fourier. Por tanto, buscamos soluciones de la forma &amp;lt;math&amp;gt;u(x,t)=\varphi(x)T(t)&amp;lt;/math&amp;gt;, donde &amp;lt;math&amp;gt;\varphi(x)&amp;lt;/math&amp;gt; satisface el siguiente problema de autovalores:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{cases}&lt;br /&gt;
\varphi’’(x)+\lambda\varphi(x)=0 ;\\&lt;br /&gt;
\varphi(0)=0; \varphi’(3)=0&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
La solución de la ecuación diferencial es &amp;lt;math&amp;gt;\varphi(x)=a\cos(\sqrt{\lambda}x)+b\sin(\sqrt{\lambda}x)&amp;lt;/math&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Aplicando las condiciones de frontera obtenemos los autovalores &amp;lt;math&amp;gt;\mu_k&amp;lt;/math&amp;gt; y autofunciones &amp;lt;math&amp;gt;\varphi_k(x)&amp;lt;/math&amp;gt; del problema&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\varphi(0)=0 \rightarrow a=0&amp;lt;/math&amp;gt;;&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\varphi’(3)=0 \rightarrow \sqrt{\lambda}b\cos(\sqrt{\lambda}\,3)=0 \rightarrow \sqrt{\lambda}\,3=(k-{1\over2})\pi \rightarrow \lambda=\mu_k=(k-{1\over2})^2{\pi^2\over9}&amp;lt;/math&amp;gt;;&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Así &amp;lt;math&amp;gt;\boldsymbol{\varphi_k(x)=\sin(k-{1\over2}){\pi\over3}x} \qquad k=1,2,3…N&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Si aplicamos que &amp;lt;math&amp;gt;u_k(x,t)=\varphi_k(x)T_k(t)&amp;lt;/math&amp;gt; satisface la ecuación diferencial &amp;lt;math&amp;gt;u_t-u{xx}=0&amp;lt;/math&amp;gt;, obtenemos la ecuación diferencial que determina &amp;lt;math&amp;gt;T_k(t)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;u_t-u{xx}=0 \rightarrow \varphi_k(x)T_k’(t)-\varphi_k’’(x)T_k(t)=\varphi_k(x)T_k’(t)-(-\mu_k)\varphi_k(x)T_k(t)=0 \rightarrow T_k’(t)+\mu_kT_k(t)=0&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
La solución de esta ecuación diferencial es &amp;lt;math&amp;gt;T_k(t)=C_ke^{-\mu_kt}= C_ke^{-(k-{1\over2})^2{\pi^2\over9}t}&amp;lt;/math&amp;gt; y por tanto &amp;lt;math&amp;gt;u_k(x,t)= \varphi_k(x)T_k(t)=C_ke^{-(k-{1\over2})^2{\pi^2\over9}t}\sin(k-{1\over2}){\pi\over3}x&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Si expresamos la solución del problema como &amp;lt;math&amp;gt;u(x,t)=\sum_{k=1}^Nu_k(x,t)= \sum_{k=1}^N C_ke^{-(k-{1\over2})^2{\pi^2\over9}t}\sin(k-{1\over2}){\pi\over3}x&amp;lt;/math&amp;gt; y hacemos que satisfaga la condición inicial obtenemos &amp;lt;math&amp;gt;u(x,0)=\sum_{k=1}^NC_k\sin(k-{1\over2}){\pi\over3}x&amp;lt;/math&amp;gt;. De esta forma, por unicidad de los coeficientes de Fourier, los coeficientes &amp;lt;math&amp;gt;C_k&amp;lt;/math&amp;gt; coinciden con los de la serie de Fourier con respecto a las autofunciones &amp;lt;math&amp;gt;\varphi_k(x)&amp;lt;/math&amp;gt; de la función a trozos que determina la condición inicial (expresada al principio del artículo).&lt;br /&gt;
&lt;br /&gt;
El problema se limita así al cálculo de dichos coeficientes, de acuerdo con la expresión&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;C_k={\int_{0}^{3}u(x,0)\varphi_k(x)dx\over\int_{0}^{3}\varphi_k^2(x)dx}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
El grado de exactitud de la aproximación con este método depende del número de elementos de la serie de Fourier, es decir, del valor de &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;. Estudiamos la temperatura de la varilla tomando los valores &amp;lt;math&amp;gt;k=1,3,5,10,20&amp;lt;/math&amp;gt;, como se puede ver en la siguiente imagen. En ella se aprecia, sobre todo en la condición inicial, que a medida que se aumente el valor de &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; la función aproximada se acerca más a la real.&lt;br /&gt;
&lt;br /&gt;
Estos resultados se pueden comparar mejor tomando un instante fijo &amp;lt;math&amp;gt;t=0.5&amp;lt;/math&amp;gt; y representando en él cada función en una misma gráfica, como podemos ver a continuación.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
First, we must assume that the fluid velocity before reaching the plate is constant, as in remote areas after passing the plate.&lt;br /&gt;
&lt;br /&gt;
In our case we take this constant as &amp;lt;math&amp;gt;2&amp;lt;/math&amp;gt;, such that&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\overrightarrow{u} =  u_0\cdot\overrightarrow{i}, u_0 = 2 &amp;lt;/math&amp;gt;&lt;br /&gt;
[[Archivo:Flujo.png|thumb|200px|left|Laminar fluid with velocity &amp;lt;math&amp;gt; u_0 &amp;lt;/math&amp;gt;]]&lt;br /&gt;
&lt;br /&gt;
Then, we must define the fluid stream function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\psi(x,y)  =  \sqrt[]{ \nu \cdot\ u_0 \cdot x} f(\eta)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where we take the viscosity &amp;lt;math&amp;gt; \nu &amp;lt;/math&amp;gt; as a unit value and&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\eta  = y  \sqrt[]{ \frac{u_0}{\nu x}}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt; f(\eta) &amp;lt;/math&amp;gt; Satisfies the Blasius equation, and therefore we will raise the initial value problem associated with this equation with the following initial conditions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{cases}&lt;br /&gt;
f’’’(\eta)+\frac{1}{2}f(\eta)f’’(\eta)=0 ; \\&lt;br /&gt;
f(0)=f’(0)=0, \lim_{\eta \to \infty}f’(\eta)= 1 ;&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
However, on time of programming we cannot introduce a conditional limit, so we have to replace them by the condition &amp;lt;math&amp;gt; f’’(0)=k &amp;lt;/math&amp;gt;, and vary the values of k to find the one that satisfies the limit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We cannot solve the differential equation like such, to apply the numerical methods, we need to pass it to a system of equations:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
f(\eta)=y_1,f’(\eta)=y_2,f’’(\eta)=y_3\\&lt;br /&gt;
\begin{cases}&lt;br /&gt;
y_1’=y_2;\\&lt;br /&gt;
y_2’=y_3;\\&lt;br /&gt;
y_3’=-\frac{1}{2}y_1y_3;\\&lt;br /&gt;
y_1(0)=y_2(0)=0; y_3(0)=k&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once the system has been formulated , we start to solve it.&lt;br /&gt;
&lt;br /&gt;
== Resolution with the modified Euler method ==&lt;br /&gt;
Then is exposed the Matlab code that numerically that solves the Blasius equation for different values of &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; , with &amp;lt;math&amp;gt; k \in \mbox{(0,1;1)}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;dk=0,01&amp;lt;/math&amp;gt;   ,with &amp;lt;math&amp;gt; \eta \in \mbox{(0,20)}&amp;lt;/math&amp;gt; and with &amp;lt;math&amp;gt;h=0,05&amp;lt;/math&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
%Resolution of Blasius equation(with modified Euler)&lt;br /&gt;
clear all&lt;br /&gt;
%Initial conditions&lt;br /&gt;
t0=0;&lt;br /&gt;
tN=20;&lt;br /&gt;
h=0.05;&lt;br /&gt;
N=(tN-t0)/h;&lt;br /&gt;
F2=zeros(91,401);%We create the matrix F2 where we will store the different&lt;br /&gt;
%solutions of f2 for each value of k&lt;br /&gt;
for k=0.1:0.01:1&lt;br /&gt;
y=[0;0;k];&lt;br /&gt;
y1=y(1);&lt;br /&gt;
y2=y(2);&lt;br /&gt;
y3=y(3);&lt;br /&gt;
for n=1:N&lt;br /&gt;
    A=[0 1 0;0 0 1;(-y(3)/2) 0 0]; %To simplify and solve using matrices, we create&lt;br /&gt;
 %the matrix A in the loop with different values of f3&lt;br /&gt;
    z=y+h*A*y;&lt;br /&gt;
    y=y+(h/2)*(A*y+A*z);&lt;br /&gt;
    y1(n+1)=y(1);&lt;br /&gt;
    y2(n+1)=y(2);&lt;br /&gt;
    y3(n+1)=y(3);&lt;br /&gt;
end&lt;br /&gt;
t=[t0:h:tN];&lt;br /&gt;
num=int8(100*(k-0.1+0.01));&lt;br /&gt;
%F2 has as rows approximations of y2 for the different values of k&lt;br /&gt;
F2(num,:)=y2;&lt;br /&gt;
end&lt;br /&gt;
k1=[0.1:0.01:1]; %Vector to represent the values of f2 in 20&lt;br /&gt;
f20=F2(:,401);&lt;br /&gt;
f20=f20';&lt;br /&gt;
o=ones(1,91);%We represented f = 1 for better viewing&lt;br /&gt;
figure(1)&lt;br /&gt;
hold on&lt;br /&gt;
plot(k1,f20,'+')&lt;br /&gt;
plot(k1,o,'r') &lt;br /&gt;
xlabel('k')&lt;br /&gt;
ylabel('f´(20)')&lt;br /&gt;
legend('f´(20)','y=1')&lt;br /&gt;
hold off&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo:Graficaf'(20)M.jpg|thumb|500px|left|Graph of &amp;lt;math&amp;gt;f’(20)&amp;lt;/math&amp;gt;  for each &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; ]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
As noted in the graph the value for which the function is closer to &amp;lt;math&amp;gt;1&amp;lt;/math&amp;gt; is &amp;lt;math&amp;gt;k=0,33&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Resolution with 4th order Runge-Kutta method==&lt;br /&gt;
Then is exposed the Matlab code that numerically that solves the Blasius equation for different values of &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; , with &amp;lt;math&amp;gt; k \in \mbox{(0,1;1)}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;dk=0,01&amp;lt;/math&amp;gt;   ,with &amp;lt;math&amp;gt; \eta \in \mbox{(0,20)}&amp;lt;/math&amp;gt; and with &amp;lt;math&amp;gt;h=0,05&amp;lt;/math&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
% Resolution of Blasius  equation(with Runge-Kutta)&lt;br /&gt;
clear all&lt;br /&gt;
t0=0;&lt;br /&gt;
tN=20;&lt;br /&gt;
h=0.05;&lt;br /&gt;
N=(tN-t0)/h;&lt;br /&gt;
F2=zeros(91,401);&lt;br /&gt;
for k=0.1:0.01:1&lt;br /&gt;
y=[0;0;k];&lt;br /&gt;
y1=y(1);&lt;br /&gt;
y2=y(2);&lt;br /&gt;
y3=y(3);&lt;br /&gt;
for n=1:N&lt;br /&gt;
    A=[0 1 0;0 0 1;(-y(3)/2) 0 0];&lt;br /&gt;
    k1=A*y;&lt;br /&gt;
    k2=A*(y+(h/2)*k1);&lt;br /&gt;
    k3=A*(y+(h/2)*k2);&lt;br /&gt;
    k4=A*(y+h*k3);&lt;br /&gt;
    y=y+(h/6)*(k1+2*k2+2*k3+k4);&lt;br /&gt;
    y1(n+1)=y(1);&lt;br /&gt;
    y2(n+1)=y(2);&lt;br /&gt;
    y3(n+1)=y(3);&lt;br /&gt;
end&lt;br /&gt;
t=[t0:h:tN];&lt;br /&gt;
num=int8(100*(k-0.1+0.01));&lt;br /&gt;
%F2 has as rows approximations of y2 for the different values of k &lt;br /&gt;
F2(num,:)=y2;&lt;br /&gt;
end&lt;br /&gt;
t=[t0:h:tN];&lt;br /&gt;
k1=[0.1:0.01:1];&lt;br /&gt;
f20=F2(:,401);&lt;br /&gt;
f20=f20';&lt;br /&gt;
o=ones(1,91);&lt;br /&gt;
figure(1)&lt;br /&gt;
hold on&lt;br /&gt;
plot(k1,f20,'+')&lt;br /&gt;
plot(k1,o,'r')&lt;br /&gt;
xlabel('k')&lt;br /&gt;
ylabel('f´(20)')&lt;br /&gt;
legend('f´(20)','y=1')&lt;br /&gt;
hold off&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[Archivo: Graficaf'(20)RK.jpg|thumb|500px|left|Graph of &amp;lt;math&amp;gt;f’(20)&amp;lt;/math&amp;gt;  for each &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Resolution with Euler method==&lt;br /&gt;
Then is exposed the Matlab code that numerically that solves the Blasius equation for different values of &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; , with &amp;lt;math&amp;gt; k \in \mbox{(0,1;1)}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;dk=0,01&amp;lt;/math&amp;gt;   ,with &amp;lt;math&amp;gt; \eta \in \mbox{(0,20)}&amp;lt;/math&amp;gt; and with &amp;lt;math&amp;gt;h=0,05&amp;lt;/math&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
%Resolution of Blasius  equation(with Euler)&lt;br /&gt;
&lt;br /&gt;
clear all&lt;br /&gt;
t0=0;&lt;br /&gt;
tN=20;&lt;br /&gt;
h=0.05;&lt;br /&gt;
N=(tN-t0)/h;&lt;br /&gt;
F2=zeros(91,401);&lt;br /&gt;
for k=0.1:0.01:1&lt;br /&gt;
y=[0;0;k];&lt;br /&gt;
y1=y(1);&lt;br /&gt;
y2=y(2);&lt;br /&gt;
y3=y(3);&lt;br /&gt;
for n=1:N&lt;br /&gt;
    A=[0 1 0;0 0 1;(-y(3)/2) 0 0];&lt;br /&gt;
    y=y+h*A*y;&lt;br /&gt;
    y1(n+1)=y(1);&lt;br /&gt;
    y2(n+1)=y(2);&lt;br /&gt;
    y3(n+1)=y(3);&lt;br /&gt;
end&lt;br /&gt;
t=[t0:h:tN];&lt;br /&gt;
num=int8(100*(k-0.1+0.01));&lt;br /&gt;
%F2 has as rows approximations of y2 for the different values of k &lt;br /&gt;
F2(num,:)=y2;&lt;br /&gt;
end&lt;br /&gt;
t=[t0:h:tN];&lt;br /&gt;
k1=[0.1:0.01:1];&lt;br /&gt;
f20=F2(:,401);&lt;br /&gt;
f20=f20';&lt;br /&gt;
o=ones(1,91);&lt;br /&gt;
figure(1)&lt;br /&gt;
hold on&lt;br /&gt;
plot(k1,f20,'+')&lt;br /&gt;
plot(k1,o,'r')&lt;br /&gt;
xlabel('k')&lt;br /&gt;
ylabel('f´(20)')&lt;br /&gt;
legend('f´(20)','y=1')&lt;br /&gt;
hold off&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[Archivo: Graficaf'(20).jpg|thumb|500px|left|Graph of &amp;lt;math&amp;gt;f’(20)&amp;lt;/math&amp;gt;  for each &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;]]&lt;br /&gt;
|}&lt;br /&gt;
== Conclusion==&lt;br /&gt;
Comparing the graphs, we see that the difference between modified Euler and 4th order Runge Kutta methods is minimal and the value for each parameter is &amp;lt;math&amp;gt;k=0,33&amp;lt;/math&amp;gt; , on the other hand, by using the Euler method (less accurate than the above) the value of the parameter is &amp;lt;math&amp;gt;k=0,32&amp;lt;/math&amp;gt;, although graphically this difference is hardly seen.&lt;br /&gt;
&lt;br /&gt;
==Graph of &amp;lt;math&amp;gt;f´(\eta)&amp;lt;/math&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The graph of &amp;lt;math&amp;gt;f'(\eta)&amp;lt;/math&amp;gt;has been realized in &amp;lt;math&amp;gt;\eta \in \mbox {(0,20)}&amp;lt;/math&amp;gt; for the value of parameter &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; obtained in the modified Euler method, ie &amp;lt;math&amp;gt;k=0.33&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To get this graph we add into the modified Euler method, the following MATLAB code:&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
&lt;br /&gt;
%We plot f2 for k = 0.33 which is in row 24 of the matrix&lt;br /&gt;
f2=F2(24,:);&lt;br /&gt;
figure(2)&lt;br /&gt;
plot(t,f2,'*')&lt;br /&gt;
xlabel('\eta')&lt;br /&gt;
ylabel('f´(\eta)')&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| [[Archivo: Graficaf'eta.jpg|thumb|800px|left|Graph of &amp;lt;math&amp;gt;f´(\eta)&amp;lt;/math&amp;gt; for &amp;lt;math&amp;gt;k=0,33&amp;lt;/math&amp;gt; ]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As can be seen, if we run the full program and see the vector &amp;lt;math&amp;gt;f2&amp;lt;/math&amp;gt; the value of &amp;lt;math&amp;gt;\eta_0&amp;lt;/math&amp;gt; for which &amp;lt;math&amp;gt;\ \vert f'(\eta)-1 \vert &amp;lt; 0,01&amp;lt;/math&amp;gt; , if &amp;lt;math&amp;gt;\eta&amp;gt;\eta _0&amp;lt;/math&amp;gt;, is &amp;lt;math&amp;gt;\eta_0\ge5,95&amp;lt;/math&amp;gt; for &amp;lt;math&amp;gt; \eta \in \mbox{(0,20)}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Horizontal velocity of the fluid=&lt;br /&gt;
Once we have numerically calculated the &amp;lt;math&amp;gt;f( \eta)&amp;lt;/math&amp;gt; we proceed to calculate the horizontal component of the fluid velocity &amp;lt;math&amp;gt; u_1 &amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\vec{u}=(u_1,u_2)=(\frac{\partial \psi}{\partial y},-\frac{\partial \psi}{\partial x})&amp;lt;/math&amp;gt;  Thus, as defined above:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;u_1=\frac{\partial \psi}{\partial y}=\frac{\partial }{\partial y}(\sqrt[]{\nu u_0 x} f(\eta))= \sqrt[]{\nu u_0 x} \frac{\partial f(\eta)}{\partial y}=\sqrt[]{\nu u_0 x} \frac{\partial f(\eta)}{\partial \eta} \frac{\partial \eta}{\partial y}=\sqrt[]{\nu u_0 x} \sqrt[]{\frac{u_0}{\nu x}} f’(\eta)=u_0 f’(\eta)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To translate this result graphically we calculate &amp;lt;math&amp;gt;u_1(x_k,y)&amp;lt;/math&amp;gt; with the Modified Euler method where &amp;lt;math&amp;gt;x_k=0.05,0.2,0.4,0.6,0.8&amp;lt;/math&amp;gt;  and &amp;lt;math&amp;gt;y \in \mbox{(0,3)}&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;h=0.01&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
%We calculate u1 with the different values of xk(with modified Euler)&lt;br /&gt;
clear all&lt;br /&gt;
xk=[0.05,0.2,0.4,0.6,0.8];&lt;br /&gt;
nu=1; u0=2;&lt;br /&gt;
y0=0; yN=3; hy=0.01;&lt;br /&gt;
N=(yN-y0)/hy;&lt;br /&gt;
y=y0:hy:yN;&lt;br /&gt;
for m=1:5&lt;br /&gt;
%We define eta ('t') for each value of  xk, each one &lt;br /&gt;
%corresponding to a row, and with 'y' in (0,3)&lt;br /&gt;
t(m,:)=sqrt(u0/(nu*xk(m)))*y;&lt;br /&gt;
h=sqrt(u0/(nu*xk(m)))*0.01;&lt;br /&gt;
f0=[0;0;0.33];&lt;br /&gt;
f=[f0(1);f0(2);f0(3)];&lt;br /&gt;
for n=1:N&lt;br /&gt;
    A=[0 1 0;0 0 1;(-f0(3)/2) 0 0];&lt;br /&gt;
    z=f0+h*A*f0;&lt;br /&gt;
    f0=f0+(h/2)*(A*f0+A*z);&lt;br /&gt;
    f(:,n+1)=[f0(1);f0(2);f0(3)];&lt;br /&gt;
end&lt;br /&gt;
Y(m,:)=f(2,:);&lt;br /&gt;
end&lt;br /&gt;
F=u0*Y;&lt;br /&gt;
hold on&lt;br /&gt;
plot(y,F(1,:),'k')&lt;br /&gt;
plot(y,F(2,:))&lt;br /&gt;
plot(y,F(3,:),'r')&lt;br /&gt;
plot(y,F(4,:),'m')&lt;br /&gt;
plot(y,F(5,:),'g')&lt;br /&gt;
legend('u_{1} for x_{k}=0.05','u_{1} for x_{k}=0.2','u_{1} for x_{k}=0.4','u_{1} for x_{k}=0.6','u_{1} for x_{k}=0.8','location','best')&lt;br /&gt;
xlabel('y')&lt;br /&gt;
ylabel('u_{1}')&lt;br /&gt;
hold off&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Archivo:Ap4a.png|thumb|800px|centre|In this picture are shown &amp;lt;math&amp;gt;5&amp;lt;/math&amp;gt; graphs, each one corresponds to a different value of &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;. ]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
According to this graph we can appreciate that the fluid, when is moving along the &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; axis, has to achieve higher height to get limit velocity &amp;lt;math&amp;gt;u_0&amp;lt;/math&amp;gt;, i.e., when the fluid moves, it must be getting over the plate to offset the perturbation that the plate causes to it ( to a higher value of &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; is greater the transition zone between zero velocity of the plate and the limit velocity &amp;lt;math&amp;gt;u_0&amp;lt;/math&amp;gt; with which the fluid initially starts).&lt;br /&gt;
&lt;br /&gt;
= Laminar boundary layer of the fluid =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
According to the above findings, it can be deduced that there is for each value of &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; a limit value  &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; from which the fluid velocity becomes constant speed again, with the same value that it had initially before reaching the area of the plate.&lt;br /&gt;
Obviously the value of the boundary layer will be related to the value &amp;lt;math&amp;gt;\eta_0&amp;lt;/math&amp;gt;, calculated above, for which the function &amp;lt;math&amp;gt;f’(\eta)&amp;lt;/math&amp;gt;  will become almost constant. The relationship is expressed as follows:&lt;br /&gt;
&amp;lt;math&amp;gt;\eta  = y  \sqrt[]{ \frac{u_0}{\nu x}}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;math&amp;gt;\eta=\eta_0&amp;lt;/math&amp;gt;, then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\eta_0=y  \sqrt[]{ \frac{2}{x}};  y=\frac{\eta_0\sqrt[]{x}}{\sqrt[]{2}}=g(x);&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Therefore we can interpret this function &amp;lt;math&amp;gt;g(x)&amp;lt;/math&amp;gt; as the fluid boundary layer. Simple Matlab code is exposed for its representation:&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
%plot function g(x)&lt;br /&gt;
x=[0:0.05:10];&lt;br /&gt;
eta0=5.95;&lt;br /&gt;
y=eta0*(x/2).^(1/2);&lt;br /&gt;
plot(x,y,'r')&lt;br /&gt;
xlabel('x')&lt;br /&gt;
ylabel('g(x)')&lt;br /&gt;
legend('g(x), interpreted as boundary layer','location','best')&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[Archivo: Figureg(x).jpg|thumb|500px|left|Graph of &amp;lt;math&amp;gt;g(x)&amp;lt;/math&amp;gt; ]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In view of the graph, the findings are similar to previous ones. As the value &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; increases, you need a higher value of &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; for the fluid velocity stabilizes and becomes the speed that we had initially.&lt;br /&gt;
&lt;br /&gt;
[[Categoría:Ecuaciones Diferenciales]]&lt;br /&gt;
[[Categoría:ED13/14]]&lt;br /&gt;
[[Categoría:Trabajos 2013-14]]&lt;/div&gt;</summary>
		<author><name>Marino Rivera</name></author>	</entry>

	<entry>
		<id>https://mat.caminos.upm.es/w/index.php?title=Boundary_layer_in_laminar_fluids_(Grupo_1B)&amp;diff=10672</id>
		<title>Boundary layer in laminar fluids (Grupo 1B)</title>
		<link rel="alternate" type="text/html" href="https://mat.caminos.upm.es/w/index.php?title=Boundary_layer_in_laminar_fluids_(Grupo_1B)&amp;diff=10672"/>
				<updated>2014-03-07T09:05:38Z</updated>
		
		<summary type="html">&lt;p&gt;Marino Rivera: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ TrabajoED |Boundary layer in laminar fluids. Grupo 1-B | [[:Categoría:Ecuaciones Diferenciales|Ecuaciones Diferenciales]]|[[:Categoría:ED13/14|Curso 2013-14]] | Sandro Andrés Martínez &lt;br /&gt;
 &lt;br /&gt;
David Ayala Díez &lt;br /&gt;
 &lt;br /&gt;
Claudia Cózar Coarasa  &lt;br /&gt;
&lt;br /&gt;
Lorena de la Fuente Sanz  &lt;br /&gt;
&lt;br /&gt;
Marino Rivera Muñoz &lt;br /&gt;
  &lt;br /&gt;
José Manuel Torres Serrano }}&lt;br /&gt;
&lt;br /&gt;
In this numerical project we have studied what happens when we introduce a flat plate in a laminar fluid whose speed and viscosity are constant.&lt;br /&gt;
&lt;br /&gt;
= Blasius equation =	&lt;br /&gt;
&lt;br /&gt;
First, we must assume that the fluid velocity before reaching the plate is constant, as in remote areas after passing the plate.&lt;br /&gt;
&lt;br /&gt;
In our case we take this constant as &amp;lt;math&amp;gt;2&amp;lt;/math&amp;gt;, such that&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\overrightarrow{u} =  u_0\cdot\overrightarrow{i}, u_0 = 2 &amp;lt;/math&amp;gt;&lt;br /&gt;
[[Archivo:Flujo.png|thumb|200px|left|Laminar fluid with velocity &amp;lt;math&amp;gt; u_0 &amp;lt;/math&amp;gt;]]&lt;br /&gt;
&lt;br /&gt;
Then, we must define the fluid stream function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\psi(x,y)  =  \sqrt[]{ \nu \cdot\ u_0 \cdot x} f(\eta)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where we take the viscosity &amp;lt;math&amp;gt; \nu &amp;lt;/math&amp;gt; as a unit value and&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\eta  = y  \sqrt[]{ \frac{u_0}{\nu x}}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt; f(\eta) &amp;lt;/math&amp;gt; Satisfies the Blasius equation, and therefore we will raise the initial value problem associated with this equation with the following initial conditions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{cases}&lt;br /&gt;
f’’’(\eta)+\frac{1}{2}f(\eta)f’’(\eta)=0 ; \\&lt;br /&gt;
f(0)=f’(0)=0, \lim_{\eta \to \infty}f’(\eta)= 1 ;&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
However, on time of programming we cannot introduce a conditional limit, so we have to replace them by the condition &amp;lt;math&amp;gt; f’’(0)=k &amp;lt;/math&amp;gt;, and vary the values of k to find the one that satisfies the limit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We cannot solve the differential equation like such, to apply the numerical methods, we need to pass it to a system of equations:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
f(\eta)=y_1,f’(\eta)=y_2,f’’(\eta)=y_3\\&lt;br /&gt;
\begin{cases}&lt;br /&gt;
y_1’=y_2;\\&lt;br /&gt;
y_2’=y_3;\\&lt;br /&gt;
y_3’=-\frac{1}{2}y_1y_3;\\&lt;br /&gt;
y_1(0)=y_2(0)=0; y_3(0)=k&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once the system has been formulated , we start to solve it.&lt;br /&gt;
&lt;br /&gt;
== Resolution with the modified Euler method ==&lt;br /&gt;
Then is exposed the Matlab code that numerically that solves the Blasius equation for different values of &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; , with &amp;lt;math&amp;gt; k \in \mbox{(0,1;1)}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;dk=0,01&amp;lt;/math&amp;gt;   ,with &amp;lt;math&amp;gt; \eta \in \mbox{(0,20)}&amp;lt;/math&amp;gt; and with &amp;lt;math&amp;gt;h=0,05&amp;lt;/math&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
%Resolution of Blasius equation(with modified Euler)&lt;br /&gt;
clear all&lt;br /&gt;
%Initial conditions&lt;br /&gt;
t0=0;&lt;br /&gt;
tN=20;&lt;br /&gt;
h=0.05;&lt;br /&gt;
N=(tN-t0)/h;&lt;br /&gt;
F2=zeros(91,401);%We create the matrix F2 where we will store the different&lt;br /&gt;
%solutions of f2 for each value of k&lt;br /&gt;
for k=0.1:0.01:1&lt;br /&gt;
y=[0;0;k];&lt;br /&gt;
y1=y(1);&lt;br /&gt;
y2=y(2);&lt;br /&gt;
y3=y(3);&lt;br /&gt;
for n=1:N&lt;br /&gt;
    A=[0 1 0;0 0 1;(-y(3)/2) 0 0]; %To simplify and solve using matrices, we create&lt;br /&gt;
 %the matrix A in the loop with different values of f3&lt;br /&gt;
    z=y+h*A*y;&lt;br /&gt;
    y=y+(h/2)*(A*y+A*z);&lt;br /&gt;
    y1(n+1)=y(1);&lt;br /&gt;
    y2(n+1)=y(2);&lt;br /&gt;
    y3(n+1)=y(3);&lt;br /&gt;
end&lt;br /&gt;
t=[t0:h:tN];&lt;br /&gt;
num=int8(100*(k-0.1+0.01));&lt;br /&gt;
%F2 has as rows approximations of y2 for the different values of k&lt;br /&gt;
F2(num,:)=y2;&lt;br /&gt;
end&lt;br /&gt;
k1=[0.1:0.01:1]; %Vector to represent the values of f2 in 20&lt;br /&gt;
f20=F2(:,401);&lt;br /&gt;
f20=f20';&lt;br /&gt;
o=ones(1,91);%We represented f = 1 for better viewing&lt;br /&gt;
figure(1)&lt;br /&gt;
hold on&lt;br /&gt;
plot(k1,f20,'+')&lt;br /&gt;
plot(k1,o,'r') &lt;br /&gt;
xlabel('k')&lt;br /&gt;
ylabel('f´(20)')&lt;br /&gt;
legend('f´(20)','y=1')&lt;br /&gt;
hold off&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo:Graficaf'(20)M.jpg|thumb|500px|left|Graph of &amp;lt;math&amp;gt;f’(20)&amp;lt;/math&amp;gt;  for each &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; ]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
As noted in the graph the value for which the function is closer to &amp;lt;math&amp;gt;1&amp;lt;/math&amp;gt; is &amp;lt;math&amp;gt;k=0,33&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Resolution with 4th order Runge-Kutta method==&lt;br /&gt;
Then is exposed the Matlab code that numerically that solves the Blasius equation for different values of &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; , with &amp;lt;math&amp;gt; k \in \mbox{(0,1;1)}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;dk=0,01&amp;lt;/math&amp;gt;   ,with &amp;lt;math&amp;gt; \eta \in \mbox{(0,20)}&amp;lt;/math&amp;gt; and with &amp;lt;math&amp;gt;h=0,05&amp;lt;/math&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
% Resolution of Blasius  equation(with Runge-Kutta)&lt;br /&gt;
clear all&lt;br /&gt;
t0=0;&lt;br /&gt;
tN=20;&lt;br /&gt;
h=0.05;&lt;br /&gt;
N=(tN-t0)/h;&lt;br /&gt;
F2=zeros(91,401);&lt;br /&gt;
for k=0.1:0.01:1&lt;br /&gt;
y=[0;0;k];&lt;br /&gt;
y1=y(1);&lt;br /&gt;
y2=y(2);&lt;br /&gt;
y3=y(3);&lt;br /&gt;
for n=1:N&lt;br /&gt;
    A=[0 1 0;0 0 1;(-y(3)/2) 0 0];&lt;br /&gt;
    k1=A*y;&lt;br /&gt;
    k2=A*(y+(h/2)*k1);&lt;br /&gt;
    k3=A*(y+(h/2)*k2);&lt;br /&gt;
    k4=A*(y+h*k3);&lt;br /&gt;
    y=y+(h/6)*(k1+2*k2+2*k3+k4);&lt;br /&gt;
    y1(n+1)=y(1);&lt;br /&gt;
    y2(n+1)=y(2);&lt;br /&gt;
    y3(n+1)=y(3);&lt;br /&gt;
end&lt;br /&gt;
t=[t0:h:tN];&lt;br /&gt;
num=int8(100*(k-0.1+0.01));&lt;br /&gt;
%F2 has as rows approximations of y2 for the different values of k &lt;br /&gt;
F2(num,:)=y2;&lt;br /&gt;
end&lt;br /&gt;
t=[t0:h:tN];&lt;br /&gt;
k1=[0.1:0.01:1];&lt;br /&gt;
f20=F2(:,401);&lt;br /&gt;
f20=f20';&lt;br /&gt;
o=ones(1,91);&lt;br /&gt;
figure(1)&lt;br /&gt;
hold on&lt;br /&gt;
plot(k1,f20,'+')&lt;br /&gt;
plot(k1,o,'r')&lt;br /&gt;
xlabel('k')&lt;br /&gt;
ylabel('f´(20)')&lt;br /&gt;
legend('f´(20)','y=1')&lt;br /&gt;
hold off&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[Archivo: Graficaf'(20)RK.jpg|thumb|500px|left|Graph of &amp;lt;math&amp;gt;f’(20)&amp;lt;/math&amp;gt;  for each &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Resolution with Euler method==&lt;br /&gt;
Then is exposed the Matlab code that numerically that solves the Blasius equation for different values of &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; , with &amp;lt;math&amp;gt; k \in \mbox{(0,1;1)}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;dk=0,01&amp;lt;/math&amp;gt;   ,with &amp;lt;math&amp;gt; \eta \in \mbox{(0,20)}&amp;lt;/math&amp;gt; and with &amp;lt;math&amp;gt;h=0,05&amp;lt;/math&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
%Resolution of Blasius  equation(with Euler)&lt;br /&gt;
&lt;br /&gt;
clear all&lt;br /&gt;
t0=0;&lt;br /&gt;
tN=20;&lt;br /&gt;
h=0.05;&lt;br /&gt;
N=(tN-t0)/h;&lt;br /&gt;
F2=zeros(91,401);&lt;br /&gt;
for k=0.1:0.01:1&lt;br /&gt;
y=[0;0;k];&lt;br /&gt;
y1=y(1);&lt;br /&gt;
y2=y(2);&lt;br /&gt;
y3=y(3);&lt;br /&gt;
for n=1:N&lt;br /&gt;
    A=[0 1 0;0 0 1;(-y(3)/2) 0 0];&lt;br /&gt;
    y=y+h*A*y;&lt;br /&gt;
    y1(n+1)=y(1);&lt;br /&gt;
    y2(n+1)=y(2);&lt;br /&gt;
    y3(n+1)=y(3);&lt;br /&gt;
end&lt;br /&gt;
t=[t0:h:tN];&lt;br /&gt;
num=int8(100*(k-0.1+0.01));&lt;br /&gt;
%F2 has as rows approximations of y2 for the different values of k &lt;br /&gt;
F2(num,:)=y2;&lt;br /&gt;
end&lt;br /&gt;
t=[t0:h:tN];&lt;br /&gt;
k1=[0.1:0.01:1];&lt;br /&gt;
f20=F2(:,401);&lt;br /&gt;
f20=f20';&lt;br /&gt;
o=ones(1,91);&lt;br /&gt;
figure(1)&lt;br /&gt;
hold on&lt;br /&gt;
plot(k1,f20,'+')&lt;br /&gt;
plot(k1,o,'r')&lt;br /&gt;
xlabel('k')&lt;br /&gt;
ylabel('f´(20)')&lt;br /&gt;
legend('f´(20)','y=1')&lt;br /&gt;
hold off&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[Archivo: Graficaf'(20).jpg|thumb|500px|left|Graph of &amp;lt;math&amp;gt;f’(20)&amp;lt;/math&amp;gt;  for each &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;]]&lt;br /&gt;
|}&lt;br /&gt;
== Conclusion==&lt;br /&gt;
Comparing the graphs, we see that the difference between modified Euler and 4th order Runge Kutta methods is minimal and the value for each parameter is &amp;lt;math&amp;gt;k=0,33&amp;lt;/math&amp;gt; , on the other hand, by using the Euler method (less accurate than the above) the value of the parameter is &amp;lt;math&amp;gt;k=0,32&amp;lt;/math&amp;gt;, although graphically this difference is hardly seen.&lt;br /&gt;
&lt;br /&gt;
==Graph of &amp;lt;math&amp;gt;f´(\eta)&amp;lt;/math&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The graph of &amp;lt;math&amp;gt;f'(\eta)&amp;lt;/math&amp;gt;has been realized in &amp;lt;math&amp;gt;\eta \in \mbox {(0,20)}&amp;lt;/math&amp;gt; for the value of parameter &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; obtained in the modified Euler method, ie &amp;lt;math&amp;gt;k=0.33&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To get this graph we add into the modified Euler method, the following MATLAB code:&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
&lt;br /&gt;
%We plot f2 for k = 0.33 which is in row 24 of the matrix&lt;br /&gt;
f2=F2(24,:);&lt;br /&gt;
figure(2)&lt;br /&gt;
plot(t,f2,'*')&lt;br /&gt;
xlabel('\eta')&lt;br /&gt;
ylabel('f´(\eta)')&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| [[Archivo: Graficaf'eta.jpg|thumb|800px|left|Graph of &amp;lt;math&amp;gt;f´(\eta)&amp;lt;/math&amp;gt; for &amp;lt;math&amp;gt;k=0,33&amp;lt;/math&amp;gt; ]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As can be seen, if we run the full program and see the vector &amp;lt;math&amp;gt;f2&amp;lt;/math&amp;gt; the value of &amp;lt;math&amp;gt;\eta_0&amp;lt;/math&amp;gt; for which &amp;lt;math&amp;gt;\ \vert f'(\eta)-1 \vert &amp;lt; 0,01&amp;lt;/math&amp;gt; , if &amp;lt;math&amp;gt;\eta&amp;gt;\eta _0&amp;lt;/math&amp;gt;, is &amp;lt;math&amp;gt;\eta_0\ge5,95&amp;lt;/math&amp;gt; for &amp;lt;math&amp;gt; \eta \in \mbox{(0,20)}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Horizontal velocity of the fluid=&lt;br /&gt;
Once we have numerically calculated the &amp;lt;math&amp;gt;f( \eta)&amp;lt;/math&amp;gt; we proceed to calculate the horizontal component of the fluid velocity &amp;lt;math&amp;gt; u_1 &amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\vec{u}=(u_1,u_2)=(\frac{\partial \psi}{\partial y},-\frac{\partial \psi}{\partial x})&amp;lt;/math&amp;gt;  Thus, as defined above:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;u_1=\frac{\partial \psi}{\partial y}=\frac{\partial }{\partial y}(\sqrt[]{\nu u_0 x} f(\eta))= \sqrt[]{\nu u_0 x} \frac{\partial f(\eta)}{\partial y}=\sqrt[]{\nu u_0 x} \frac{\partial f(\eta)}{\partial \eta} \frac{\partial \eta}{\partial y}=\sqrt[]{\nu u_0 x} \sqrt[]{\frac{u_0}{\nu x}} f’(\eta)=u_0 f’(\eta)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To translate this result graphically we calculate &amp;lt;math&amp;gt;u_1(x_k,y)&amp;lt;/math&amp;gt; with the Modified Euler method where &amp;lt;math&amp;gt;x_k=0.05,0.2,0.4,0.6,0.8&amp;lt;/math&amp;gt;  and &amp;lt;math&amp;gt;y \in \mbox{(0,3)}&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;h=0.01&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
%We calculate u1 with the different values of xk(with modified Euler)&lt;br /&gt;
clear all&lt;br /&gt;
xk=[0.05,0.2,0.4,0.6,0.8];&lt;br /&gt;
nu=1; u0=2;&lt;br /&gt;
y0=0; yN=3; hy=0.01;&lt;br /&gt;
N=(yN-y0)/hy;&lt;br /&gt;
y=y0:hy:yN;&lt;br /&gt;
for m=1:5&lt;br /&gt;
%We define eta ('t') for each value of  xk, each one &lt;br /&gt;
%corresponding to a row, and with 'y' in (0,3)&lt;br /&gt;
t(m,:)=sqrt(u0/(nu*xk(m)))*y;&lt;br /&gt;
h=sqrt(u0/(nu*xk(m)))*0.01;&lt;br /&gt;
f0=[0;0;0.33];&lt;br /&gt;
f=[f0(1);f0(2);f0(3)];&lt;br /&gt;
for n=1:N&lt;br /&gt;
    A=[0 1 0;0 0 1;(-f0(3)/2) 0 0];&lt;br /&gt;
    z=f0+h*A*f0;&lt;br /&gt;
    f0=f0+(h/2)*(A*f0+A*z);&lt;br /&gt;
    f(:,n+1)=[f0(1);f0(2);f0(3)];&lt;br /&gt;
end&lt;br /&gt;
Y(m,:)=f(2,:);&lt;br /&gt;
end&lt;br /&gt;
F=u0*Y;&lt;br /&gt;
hold on&lt;br /&gt;
plot(y,F(1,:),'k')&lt;br /&gt;
plot(y,F(2,:))&lt;br /&gt;
plot(y,F(3,:),'r')&lt;br /&gt;
plot(y,F(4,:),'m')&lt;br /&gt;
plot(y,F(5,:),'g')&lt;br /&gt;
legend('u_{1} for x_{k}=0.05','u_{1} for x_{k}=0.2','u_{1} for x_{k}=0.4','u_{1} for x_{k}=0.6','u_{1} for x_{k}=0.8','location','best')&lt;br /&gt;
xlabel('y')&lt;br /&gt;
ylabel('u_{1}')&lt;br /&gt;
hold off&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Archivo:Ap4a.png|thumb|800px|centre|In this picture are shown &amp;lt;math&amp;gt;5&amp;lt;/math&amp;gt; graphs, each one corresponds to a different value of &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;. ]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
According to this graph we can appreciate that the fluid, when is moving along the &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; axis, has to achieve higher height to get limit velocity &amp;lt;math&amp;gt;u_0&amp;lt;/math&amp;gt;, i.e., when the fluid moves, it must be getting over the plate to offset the perturbation that the plate causes to it ( to a higher value of &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; is greater the transition zone between zero velocity of the plate and the limit velocity &amp;lt;math&amp;gt;u_0&amp;lt;/math&amp;gt; with which the fluid initially starts).&lt;br /&gt;
&lt;br /&gt;
= Laminar boundary layer of the fluid =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
According to the above findings, it can be deduced that there is for each value of &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; a limit value  &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; from which the fluid velocity becomes constant speed again, with the same value that it had initially before reaching the area of the plate.&lt;br /&gt;
Obviously the value of the boundary layer will be related to the value &amp;lt;math&amp;gt;\eta_0&amp;lt;/math&amp;gt;, calculated above, for which the function &amp;lt;math&amp;gt;f’(\eta)&amp;lt;/math&amp;gt;  will become almost constant. The relationship is expressed as follows:&lt;br /&gt;
&amp;lt;math&amp;gt;\eta  = y  \sqrt[]{ \frac{u_0}{\nu x}}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;math&amp;gt;\eta=\eta_0&amp;lt;/math&amp;gt;, then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\eta_0=y  \sqrt[]{ \frac{2}{x}};  y=\frac{\eta_0\sqrt[]{x}}{\sqrt[]{2}}=g(x);&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Therefore we can interpret this function &amp;lt;math&amp;gt;g(x)&amp;lt;/math&amp;gt; as the fluid boundary layer. Simple Matlab code is exposed for its representation:&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
%plot function g(x)&lt;br /&gt;
x=[0:0.05:10];&lt;br /&gt;
eta0=5.95;&lt;br /&gt;
y=eta0*(x/2).^(1/2);&lt;br /&gt;
plot(x,y,'r')&lt;br /&gt;
xlabel('x')&lt;br /&gt;
ylabel('g(x)')&lt;br /&gt;
legend('g(x), interpreted as boundary layer','location','best')&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[Archivo: Figureg(x).jpg|thumb|500px|left|Graph of &amp;lt;math&amp;gt;g(x)&amp;lt;/math&amp;gt; ]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In view of the graph, the findings are similar to previous ones. As the value &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; increases, you need a higher value of &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; for the fluid velocity stabilizes and becomes the speed that we had initially.&lt;br /&gt;
&lt;br /&gt;
[[Categoría:Ecuaciones Diferenciales]]&lt;br /&gt;
[[Categoría:ED13/14]]&lt;br /&gt;
[[Categoría:Trabajos 2013-14]]&lt;/div&gt;</summary>
		<author><name>Marino Rivera</name></author>	</entry>

	<entry>
		<id>https://mat.caminos.upm.es/w/index.php?title=Boundary_layer_in_laminar_fluids_(Grupo_1B)&amp;diff=10671</id>
		<title>Boundary layer in laminar fluids (Grupo 1B)</title>
		<link rel="alternate" type="text/html" href="https://mat.caminos.upm.es/w/index.php?title=Boundary_layer_in_laminar_fluids_(Grupo_1B)&amp;diff=10671"/>
				<updated>2014-03-07T09:01:32Z</updated>
		
		<summary type="html">&lt;p&gt;Marino Rivera: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ TrabajoED |Boundary layer in laminar fluids. Grupo 1-B | [[:Categoría:Ecuaciones Diferenciales|Ecuaciones Diferenciales]]|[[:Categoría:ED13/14|Curso 2013-14]] | Sandro Andrés Martínez &lt;br /&gt;
 &lt;br /&gt;
David Ayala Díez &lt;br /&gt;
 &lt;br /&gt;
Claudia Cózar Coarasa  &lt;br /&gt;
&lt;br /&gt;
Lorena de la Fuente Sanz  &lt;br /&gt;
&lt;br /&gt;
Marino Rivera Muñoz &lt;br /&gt;
  &lt;br /&gt;
José Manuel Torres Serrano }}&lt;br /&gt;
&lt;br /&gt;
In this numerical project we have studied what happens when we introduce a flat plate in a laminar fluid whose speed and viscosity are constant.&lt;br /&gt;
&lt;br /&gt;
= Blasius equation =	&lt;br /&gt;
&lt;br /&gt;
First, we must assume that the fluid velocity before reaching the plate is constant, as in remote areas after passing the plate.&lt;br /&gt;
&lt;br /&gt;
In our case we take this constant as &amp;lt;math&amp;gt;2&amp;lt;/math&amp;gt;, such that&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\overrightarrow{u} =  u_0\cdot\overrightarrow{i}, u_0 = 2 &amp;lt;/math&amp;gt;&lt;br /&gt;
[[Archivo:Flujo.png|thumb|200px|left|Laminar fluid with velocity &amp;lt;math&amp;gt; u_0 &amp;lt;/math&amp;gt;]]&lt;br /&gt;
&lt;br /&gt;
Then, we must define the fluid stream function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\psi(x,y)  =  \sqrt[]{ \nu \cdot\ u_0 \cdot x} f(\eta)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where we take the viscosity &amp;lt;math&amp;gt; \nu &amp;lt;/math&amp;gt; as a unit value and&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\eta  = y  \sqrt[]{ \frac{u_0}{\nu x}}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt; f(\eta) &amp;lt;/math&amp;gt; Satisfies the Blasius equation, and therefore we will raise the initial value problem associated with this equation with the following initial conditions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{cases}&lt;br /&gt;
f’’’(\eta)+\frac{1}{2}f(\eta)f’’(\eta)=0 ; \\&lt;br /&gt;
f(0)=f’(0)=0, \lim_{\eta \to \infty}f’(\eta)= 1 ;&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
However, on time of programming we cannot introduce a conditional limit, so we have to replace them by the condition &amp;lt;math&amp;gt; f’’(\eta)=k &amp;lt;/math&amp;gt;, and vary the values of k to find the one that satisfies the limit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We cannot solve the differential equation like such, to apply the numerical methods, we need to pass it to a system of equations:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
f(\eta)=y_1,f’(\eta)=y_2,f’’(\eta)=y_3\\&lt;br /&gt;
\begin{cases}&lt;br /&gt;
y_1’=y_2;\\&lt;br /&gt;
y_2’=y_3;\\&lt;br /&gt;
y_3’=-\frac{1}{2}y_1y_3;\\&lt;br /&gt;
y_1(0)=y_2(0)=0; y_3(0)=k&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once the system has been formulated , we start to solve it.&lt;br /&gt;
&lt;br /&gt;
== Resolution with the modified Euler method ==&lt;br /&gt;
Then is exposed the Matlab code that numerically that solves the Blasius equation for different values of &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; , with &amp;lt;math&amp;gt; k \in \mbox{(0,1;1)}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;dk=0,01&amp;lt;/math&amp;gt;   ,with &amp;lt;math&amp;gt; \eta \in \mbox{(0,20)}&amp;lt;/math&amp;gt; and with &amp;lt;math&amp;gt;h=0,05&amp;lt;/math&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
%Resolution of Blasius equation(with modified Euler)&lt;br /&gt;
clear all&lt;br /&gt;
%Initial conditions&lt;br /&gt;
t0=0;&lt;br /&gt;
tN=20;&lt;br /&gt;
h=0.05;&lt;br /&gt;
N=(tN-t0)/h;&lt;br /&gt;
F2=zeros(91,401);%We create the matrix F2 where we will store the different&lt;br /&gt;
%solutions of f2 for each value of k&lt;br /&gt;
for k=0.1:0.01:1&lt;br /&gt;
y=[0;0;k];&lt;br /&gt;
y1=y(1);&lt;br /&gt;
y2=y(2);&lt;br /&gt;
y3=y(3);&lt;br /&gt;
for n=1:N&lt;br /&gt;
    A=[0 1 0;0 0 1;(-y(3)/2) 0 0]; %To simplify and solve using matrices, we create&lt;br /&gt;
 %the matrix A in the loop with different values of f3&lt;br /&gt;
    z=y+h*A*y;&lt;br /&gt;
    y=y+(h/2)*(A*y+A*z);&lt;br /&gt;
    y1(n+1)=y(1);&lt;br /&gt;
    y2(n+1)=y(2);&lt;br /&gt;
    y3(n+1)=y(3);&lt;br /&gt;
end&lt;br /&gt;
t=[t0:h:tN];&lt;br /&gt;
num=int8(100*(k-0.1+0.01));&lt;br /&gt;
%F2 has as rows approximations of y2 for the different values of k&lt;br /&gt;
F2(num,:)=y2;&lt;br /&gt;
end&lt;br /&gt;
k1=[0.1:0.01:1]; %Vector to represent the values of f2 in 20&lt;br /&gt;
f20=F2(:,401);&lt;br /&gt;
f20=f20';&lt;br /&gt;
o=ones(1,91);%We represented f = 1 for better viewing&lt;br /&gt;
figure(1)&lt;br /&gt;
hold on&lt;br /&gt;
plot(k1,f20,'+')&lt;br /&gt;
plot(k1,o,'r') &lt;br /&gt;
xlabel('k')&lt;br /&gt;
ylabel('f´(20)')&lt;br /&gt;
legend('f´(20)','y=1')&lt;br /&gt;
hold off&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo:Graficaf'(20)M.jpg|thumb|500px|left|Graph of &amp;lt;math&amp;gt;f’(20)&amp;lt;/math&amp;gt;  for each &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; ]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
As noted in the graph the value for which the function is closer to &amp;lt;math&amp;gt;1&amp;lt;/math&amp;gt; is &amp;lt;math&amp;gt;k=0,33&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Resolution with 4th order Runge-Kutta method==&lt;br /&gt;
Then is exposed the Matlab code that numerically that solves the Blasius equation for different values of &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; , with &amp;lt;math&amp;gt; k \in \mbox{(0,1;1)}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;dk=0,01&amp;lt;/math&amp;gt;   ,with &amp;lt;math&amp;gt; \eta \in \mbox{(0,20)}&amp;lt;/math&amp;gt; and with &amp;lt;math&amp;gt;h=0,05&amp;lt;/math&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
% Resolution of Blasius  equation(with Runge-Kutta)&lt;br /&gt;
clear all&lt;br /&gt;
t0=0;&lt;br /&gt;
tN=20;&lt;br /&gt;
h=0.05;&lt;br /&gt;
N=(tN-t0)/h;&lt;br /&gt;
F2=zeros(91,401);&lt;br /&gt;
for k=0.1:0.01:1&lt;br /&gt;
y=[0;0;k];&lt;br /&gt;
y1=y(1);&lt;br /&gt;
y2=y(2);&lt;br /&gt;
y3=y(3);&lt;br /&gt;
for n=1:N&lt;br /&gt;
    A=[0 1 0;0 0 1;(-y(3)/2) 0 0];&lt;br /&gt;
    k1=A*y;&lt;br /&gt;
    k2=A*(y+(h/2)*k1);&lt;br /&gt;
    k3=A*(y+(h/2)*k2);&lt;br /&gt;
    k4=A*(y+h*k3);&lt;br /&gt;
    y=y+(h/6)*(k1+2*k2+2*k3+k4);&lt;br /&gt;
    y1(n+1)=y(1);&lt;br /&gt;
    y2(n+1)=y(2);&lt;br /&gt;
    y3(n+1)=y(3);&lt;br /&gt;
end&lt;br /&gt;
t=[t0:h:tN];&lt;br /&gt;
num=int8(100*(k-0.1+0.01));&lt;br /&gt;
%F2 has as rows approximations of y2 for the different values of k &lt;br /&gt;
F2(num,:)=y2;&lt;br /&gt;
end&lt;br /&gt;
t=[t0:h:tN];&lt;br /&gt;
k1=[0.1:0.01:1];&lt;br /&gt;
f20=F2(:,401);&lt;br /&gt;
f20=f20';&lt;br /&gt;
o=ones(1,91);&lt;br /&gt;
figure(1)&lt;br /&gt;
hold on&lt;br /&gt;
plot(k1,f20,'+')&lt;br /&gt;
plot(k1,o,'r')&lt;br /&gt;
xlabel('k')&lt;br /&gt;
ylabel('f´(20)')&lt;br /&gt;
legend('f´(20)','y=1')&lt;br /&gt;
hold off&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[Archivo: Graficaf'(20)RK.jpg|thumb|500px|left|Graph of &amp;lt;math&amp;gt;f’(20)&amp;lt;/math&amp;gt;  for each &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Resolution with Euler method==&lt;br /&gt;
Then is exposed the Matlab code that numerically that solves the Blasius equation for different values of &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; , with &amp;lt;math&amp;gt; k \in \mbox{(0,1;1)}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;dk=0,01&amp;lt;/math&amp;gt;   ,with &amp;lt;math&amp;gt; \eta \in \mbox{(0,20)}&amp;lt;/math&amp;gt; and with &amp;lt;math&amp;gt;h=0,05&amp;lt;/math&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
%Resolution of Blasius  equation(with Euler)&lt;br /&gt;
&lt;br /&gt;
clear all&lt;br /&gt;
t0=0;&lt;br /&gt;
tN=20;&lt;br /&gt;
h=0.05;&lt;br /&gt;
N=(tN-t0)/h;&lt;br /&gt;
F2=zeros(91,401);&lt;br /&gt;
for k=0.1:0.01:1&lt;br /&gt;
y=[0;0;k];&lt;br /&gt;
y1=y(1);&lt;br /&gt;
y2=y(2);&lt;br /&gt;
y3=y(3);&lt;br /&gt;
for n=1:N&lt;br /&gt;
    A=[0 1 0;0 0 1;(-y(3)/2) 0 0];&lt;br /&gt;
    y=y+h*A*y;&lt;br /&gt;
    y1(n+1)=y(1);&lt;br /&gt;
    y2(n+1)=y(2);&lt;br /&gt;
    y3(n+1)=y(3);&lt;br /&gt;
end&lt;br /&gt;
t=[t0:h:tN];&lt;br /&gt;
num=int8(100*(k-0.1+0.01));&lt;br /&gt;
%F2 has as rows approximations of y2 for the different values of k &lt;br /&gt;
F2(num,:)=y2;&lt;br /&gt;
end&lt;br /&gt;
t=[t0:h:tN];&lt;br /&gt;
k1=[0.1:0.01:1];&lt;br /&gt;
f20=F2(:,401);&lt;br /&gt;
f20=f20';&lt;br /&gt;
o=ones(1,91);&lt;br /&gt;
figure(1)&lt;br /&gt;
hold on&lt;br /&gt;
plot(k1,f20,'+')&lt;br /&gt;
plot(k1,o,'r')&lt;br /&gt;
xlabel('k')&lt;br /&gt;
ylabel('f´(20)')&lt;br /&gt;
legend('f´(20)','y=1')&lt;br /&gt;
hold off&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[Archivo: Graficaf'(20).jpg|thumb|500px|left|Graph of &amp;lt;math&amp;gt;f’(20)&amp;lt;/math&amp;gt;  for each &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;]]&lt;br /&gt;
|}&lt;br /&gt;
== Conclusion==&lt;br /&gt;
Comparing the graphs, we see that the difference between modified Euler and 4th order Runge Kutta methods is minimal and the value for each parameter is &amp;lt;math&amp;gt;k=0,33&amp;lt;/math&amp;gt; , on the other hand, by using the Euler method (less accurate than the above) the value of the parameter is &amp;lt;math&amp;gt;k=0,32&amp;lt;/math&amp;gt;, although graphically this difference is hardly seen.&lt;br /&gt;
&lt;br /&gt;
==Graph of &amp;lt;math&amp;gt;f´(\eta)&amp;lt;/math&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The graph of &amp;lt;math&amp;gt;f'(\eta)&amp;lt;/math&amp;gt;has been realized in &amp;lt;math&amp;gt;\eta \in \mbox {(0,20)}&amp;lt;/math&amp;gt; for the value of parameter &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; obtained in the modified Euler method, ie &amp;lt;math&amp;gt;k=0.33&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To get this graph we add into the modified Euler method, the following MATLAB code:&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
&lt;br /&gt;
%We plot f2 for k = 0.33 which is in row 24 of the matrix&lt;br /&gt;
f2=F2(24,:);&lt;br /&gt;
figure(2)&lt;br /&gt;
plot(t,f2,'*')&lt;br /&gt;
xlabel('\eta')&lt;br /&gt;
ylabel('f´(\eta)')&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| [[Archivo: Graficaf'eta.jpg|thumb|800px|left|Graph of &amp;lt;math&amp;gt;f´(\eta)&amp;lt;/math&amp;gt; for &amp;lt;math&amp;gt;k=0,33&amp;lt;/math&amp;gt; ]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As can be seen, if we run the full program and see the vector &amp;lt;math&amp;gt;f2&amp;lt;/math&amp;gt; the value of &amp;lt;math&amp;gt;\eta_0&amp;lt;/math&amp;gt; for which &amp;lt;math&amp;gt;\ \vert f'(\eta)-1 \vert &amp;lt; 0,01&amp;lt;/math&amp;gt; , if &amp;lt;math&amp;gt;\eta&amp;gt;\eta _0&amp;lt;/math&amp;gt;, is &amp;lt;math&amp;gt;\eta_0\ge5,95&amp;lt;/math&amp;gt; for &amp;lt;math&amp;gt; \eta \in \mbox{(0,20)}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Horizontal velocity of the fluid=&lt;br /&gt;
Once we have numerically calculated the &amp;lt;math&amp;gt;f( \eta)&amp;lt;/math&amp;gt; we proceed to calculate the horizontal component of the fluid velocity &amp;lt;math&amp;gt; u_1 &amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\vec{u}=(u_1,u_2)=(\frac{\partial \psi}{\partial y},-\frac{\partial \psi}{\partial x})&amp;lt;/math&amp;gt;  Thus, as defined above:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;u_1=\frac{\partial \psi}{\partial y}=\frac{\partial }{\partial y}(\sqrt[]{\nu u_0 x} f(\eta))= \sqrt[]{\nu u_0 x} \frac{\partial f(\eta)}{\partial y}=\sqrt[]{\nu u_0 x} \frac{\partial f(\eta)}{\partial \eta} \frac{\partial \eta}{\partial y}=\sqrt[]{\nu u_0 x} \sqrt[]{\frac{u_0}{\nu x}} f’(\eta)=u_0 f’(\eta)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To translate this result graphically we calculate &amp;lt;math&amp;gt;u_1(x_k,y)&amp;lt;/math&amp;gt; with the Modified Euler method where &amp;lt;math&amp;gt;x_k=0.05,0.2,0.4,0.6,0.8&amp;lt;/math&amp;gt;  and &amp;lt;math&amp;gt;y \in \mbox{(0,3)}&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;h=0.01&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
%We calculate u1 with the different values of xk(with modified Euler)&lt;br /&gt;
clear all&lt;br /&gt;
xk=[0.05,0.2,0.4,0.6,0.8];&lt;br /&gt;
nu=1; u0=2;&lt;br /&gt;
y0=0; yN=3; hy=0.01;&lt;br /&gt;
N=(yN-y0)/hy;&lt;br /&gt;
y=y0:hy:yN;&lt;br /&gt;
for m=1:5&lt;br /&gt;
%We define eta ('t') for each value of  xk, each one &lt;br /&gt;
%corresponding to a row, and with 'y' in (0,3)&lt;br /&gt;
t(m,:)=sqrt(u0/(nu*xk(m)))*y;&lt;br /&gt;
h=sqrt(u0/(nu*xk(m)))*0.01;&lt;br /&gt;
f0=[0;0;0.33];&lt;br /&gt;
f=[f0(1);f0(2);f0(3)];&lt;br /&gt;
for n=1:N&lt;br /&gt;
    A=[0 1 0;0 0 1;(-f0(3)/2) 0 0];&lt;br /&gt;
    z=f0+h*A*f0;&lt;br /&gt;
    f0=f0+(h/2)*(A*f0+A*z);&lt;br /&gt;
    f(:,n+1)=[f0(1);f0(2);f0(3)];&lt;br /&gt;
end&lt;br /&gt;
Y(m,:)=f(2,:);&lt;br /&gt;
end&lt;br /&gt;
F=u0*Y;&lt;br /&gt;
hold on&lt;br /&gt;
plot(y,F(1,:),'k')&lt;br /&gt;
plot(y,F(2,:))&lt;br /&gt;
plot(y,F(3,:),'r')&lt;br /&gt;
plot(y,F(4,:),'m')&lt;br /&gt;
plot(y,F(5,:),'g')&lt;br /&gt;
legend('u_{1} for x_{k}=0.05','u_{1} for x_{k}=0.2','u_{1} for x_{k}=0.4','u_{1} for x_{k}=0.6','u_{1} for x_{k}=0.8','location','best')&lt;br /&gt;
xlabel('y')&lt;br /&gt;
ylabel('u_{1}')&lt;br /&gt;
hold off&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Archivo:Ap4a.png|thumb|800px|centre|In this picture are shown &amp;lt;math&amp;gt;5&amp;lt;/math&amp;gt; graphs, each one corresponds to a different value of &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;. ]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
According to this graph we can appreciate that the fluid, when is moving along the &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; axis, has to achieve higher height to get limit velocity &amp;lt;math&amp;gt;u_0&amp;lt;/math&amp;gt;, i.e., when the fluid moves, it must be getting over the plate to offset the perturbation that the plate causes to it ( to a higher value of &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; is greater the transition zone between zero velocity of the plate and the limit velocity &amp;lt;math&amp;gt;u_0&amp;lt;/math&amp;gt; with which the fluid initially starts).&lt;br /&gt;
&lt;br /&gt;
= Laminar boundary layer of the fluid =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
According to the above findings, it can be deduced that there is for each value of &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; a limit value  &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; from which the fluid velocity becomes constant speed again, with the same value that it had initially before reaching the area of the plate.&lt;br /&gt;
Obviously the value of the boundary layer will be related to the value &amp;lt;math&amp;gt;\eta_0&amp;lt;/math&amp;gt;, calculated above, for which the function &amp;lt;math&amp;gt;f’(\eta)&amp;lt;/math&amp;gt;  will become almost constant. The relationship is expressed as follows:&lt;br /&gt;
&amp;lt;math&amp;gt;\eta  = y  \sqrt[]{ \frac{u_0}{\nu x}}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;math&amp;gt;\eta=\eta_0&amp;lt;/math&amp;gt;, then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\eta_0=y  \sqrt[]{ \frac{2}{x}};  y=\frac{\eta_0\sqrt[]{x}}{\sqrt[]{2}}=g(x);&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Therefore we can interpret this function &amp;lt;math&amp;gt;g(x)&amp;lt;/math&amp;gt; as the fluid boundary layer. Simple Matlab code is exposed for its representation:&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
%plot function g(x)&lt;br /&gt;
x=[0:0.05:10];&lt;br /&gt;
eta0=5.95;&lt;br /&gt;
y=eta0*(x/2).^(1/2);&lt;br /&gt;
plot(x,y,'r')&lt;br /&gt;
xlabel('x')&lt;br /&gt;
ylabel('g(x)')&lt;br /&gt;
legend('g(x), interpreted as boundary layer','location','best')&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[Archivo: Figureg(x).jpg|thumb|500px|left|Graph of &amp;lt;math&amp;gt;g(x)&amp;lt;/math&amp;gt; ]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In view of the graph, the findings are similar to previous ones. As the value &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; increases, you need a higher value of &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; for the fluid velocity stabilizes and becomes the speed that we had initially.&lt;br /&gt;
&lt;br /&gt;
[[Categoría:Ecuaciones Diferenciales]]&lt;br /&gt;
[[Categoría:ED13/14]]&lt;br /&gt;
[[Categoría:Trabajos 2013-14]]&lt;/div&gt;</summary>
		<author><name>Marino Rivera</name></author>	</entry>

	<entry>
		<id>https://mat.caminos.upm.es/w/index.php?title=Boundary_layer_in_laminar_fluids_(Grupo_1B)&amp;diff=10667</id>
		<title>Boundary layer in laminar fluids (Grupo 1B)</title>
		<link rel="alternate" type="text/html" href="https://mat.caminos.upm.es/w/index.php?title=Boundary_layer_in_laminar_fluids_(Grupo_1B)&amp;diff=10667"/>
				<updated>2014-03-06T23:06:48Z</updated>
		
		<summary type="html">&lt;p&gt;Marino Rivera: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ TrabajoED |Boundary layer in laminar fluids. Grupo 1-B | [[:Categoría:Ecuaciones Diferenciales|Ecuaciones Diferenciales]]|[[:Categoría:ED13/14|Curso 2013-14]] | Sandro Andrés Martínez &lt;br /&gt;
 &lt;br /&gt;
David Ayala Díez &lt;br /&gt;
 &lt;br /&gt;
Claudia Cózar Coarasa  &lt;br /&gt;
&lt;br /&gt;
Lorena de la Fuente Sanz  &lt;br /&gt;
&lt;br /&gt;
Marino Rivera Muñoz &lt;br /&gt;
  &lt;br /&gt;
José Manuel Torres Serrano }}&lt;br /&gt;
&lt;br /&gt;
In this numerical project we have studied what happens when we introduce a flat plate in a laminar fluid whose speed and viscosity are constant.&lt;br /&gt;
&lt;br /&gt;
= Blasius equation =	&lt;br /&gt;
&lt;br /&gt;
First, we must assume that the fluid velocity before reaching the plate is constant, as in remote areas after passing the plate.&lt;br /&gt;
&lt;br /&gt;
In our case we take this constant as &amp;lt;math&amp;gt;2&amp;lt;/math&amp;gt;, such that&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\overrightarrow{u} =  u_0\cdot\overrightarrow{i}, u_0 = 2 &amp;lt;/math&amp;gt;&lt;br /&gt;
[[Archivo:Flujo.png|thumb|200px|left|Laminar fluid with velocity &amp;lt;math&amp;gt; u_0 &amp;lt;/math&amp;gt;]]&lt;br /&gt;
&lt;br /&gt;
Then, we must define the fluid stream function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\psi(x,y)  =  \sqrt[]{ \nu \cdot\ u_0 \cdot x} f(\eta)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where we take the viscosity &amp;lt;math&amp;gt; \nu &amp;lt;/math&amp;gt; as a unit value and&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\eta  = y  \sqrt[]{ \frac{u_0}{\nu x}}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt; f(\nu) &amp;lt;/math&amp;gt; Satisfies the Blasius equation, and therefore we will raise the initial value problem associated with this equation with the following initial conditions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{cases}&lt;br /&gt;
f’’’(\eta)+\frac{1}{2}f(\eta)f’’(\eta)=0 ; \\&lt;br /&gt;
f(0)=f’(0)=0, \lim_{\eta \to \infty}f’(\eta)= 1 ;&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
However, on time of programming we cannot introduce a conditional limit, so we have to replace them by the condition &amp;lt;math&amp;gt; f’’(\eta)=k &amp;lt;/math&amp;gt;, and vary the values of k to find the one that satisfies the limit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We cannot solve the differential equation like such, to apply the numerical methods, we need to pass it to a system of equations:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
f(\eta)=y_1,f’(\eta)=y_2,f’’(\eta)=y_3\\&lt;br /&gt;
\begin{cases}&lt;br /&gt;
y_1’=y_2;\\&lt;br /&gt;
y_2’=y_3;\\&lt;br /&gt;
y_3’=-\frac{1}{2}y_1y_3;\\&lt;br /&gt;
y_1(0)=y_2(0)=0; y_3(0)=k&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once the system has been formulated , we start to solve it.&lt;br /&gt;
&lt;br /&gt;
== Resolution with the modified Euler method ==&lt;br /&gt;
Then is exposed the Matlab code that numerically that solves the Blasius equation for different values of &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; , with &amp;lt;math&amp;gt; k \in \mbox{(0,1;1)}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;dk=0,01&amp;lt;/math&amp;gt;   ,with &amp;lt;math&amp;gt; \eta \in \mbox{(0,20)}&amp;lt;/math&amp;gt; and with &amp;lt;math&amp;gt;h=0,05&amp;lt;/math&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
%Resolution of Blasius equation(with modified Euler)&lt;br /&gt;
clear all&lt;br /&gt;
%Initial conditions&lt;br /&gt;
t0=0;&lt;br /&gt;
tN=20;&lt;br /&gt;
h=0.05;&lt;br /&gt;
N=(tN-t0)/h;&lt;br /&gt;
F2=zeros(91,401);%We create the matrix F2 where we will store the different&lt;br /&gt;
%solutions of f2 for each value of k&lt;br /&gt;
for k=0.1:0.01:1&lt;br /&gt;
y=[0;0;k];&lt;br /&gt;
y1=y(1);&lt;br /&gt;
y2=y(2);&lt;br /&gt;
y3=y(3);&lt;br /&gt;
for n=1:N&lt;br /&gt;
    A=[0 1 0;0 0 1;(-y(3)/2) 0 0]; %To simplify and solve using matrices, we create&lt;br /&gt;
 %the matrix A in the loop with different values of f3&lt;br /&gt;
    z=y+h*A*y;&lt;br /&gt;
    y=y+(h/2)*(A*y+A*z);&lt;br /&gt;
    y1(n+1)=y(1);&lt;br /&gt;
    y2(n+1)=y(2);&lt;br /&gt;
    y3(n+1)=y(3);&lt;br /&gt;
end&lt;br /&gt;
t=[t0:h:tN];&lt;br /&gt;
num=int8(100*(k-0.1+0.01));&lt;br /&gt;
%F2 has as rows approximations of y2 for the different values of k&lt;br /&gt;
F2(num,:)=y2;&lt;br /&gt;
end&lt;br /&gt;
k1=[0.1:0.01:1]; %Vector to represent the values of f2 in 20&lt;br /&gt;
f20=F2(:,401);&lt;br /&gt;
f20=f20';&lt;br /&gt;
o=ones(1,91);%We represented f = 1 for better viewing&lt;br /&gt;
figure(1)&lt;br /&gt;
hold on&lt;br /&gt;
plot(k1,f20,'+')&lt;br /&gt;
plot(k1,o,'r') &lt;br /&gt;
xlabel('k')&lt;br /&gt;
ylabel('f´(20)')&lt;br /&gt;
legend('f´(20)','y=1')&lt;br /&gt;
hold off&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo:Graficaf'(20)M.jpg|thumb|500px|left|Graph of &amp;lt;math&amp;gt;f’(20)&amp;lt;/math&amp;gt;  for each &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; ]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
As noted in the graph the value for which the function is closer to &amp;lt;math&amp;gt;1&amp;lt;/math&amp;gt; is &amp;lt;math&amp;gt;k=0,33&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Resolution with 4th order Runge-Kutta method==&lt;br /&gt;
Then is exposed the Matlab code that numerically that solves the Blasius equation for different values of &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; , with &amp;lt;math&amp;gt; k \in \mbox{(0,1;1)}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;dk=0,01&amp;lt;/math&amp;gt;   ,with &amp;lt;math&amp;gt; \eta \in \mbox{(0,20)}&amp;lt;/math&amp;gt; and with &amp;lt;math&amp;gt;h=0,05&amp;lt;/math&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
% Resolution of Blasius  equation(with Runge-Kutta)&lt;br /&gt;
clear all&lt;br /&gt;
t0=0;&lt;br /&gt;
tN=20;&lt;br /&gt;
h=0.05;&lt;br /&gt;
N=(tN-t0)/h;&lt;br /&gt;
F2=zeros(91,401);&lt;br /&gt;
for k=0.1:0.01:1&lt;br /&gt;
y=[0;0;k];&lt;br /&gt;
y1=y(1);&lt;br /&gt;
y2=y(2);&lt;br /&gt;
y3=y(3);&lt;br /&gt;
for n=1:N&lt;br /&gt;
    A=[0 1 0;0 0 1;(-y(3)/2) 0 0];&lt;br /&gt;
    k1=A*y;&lt;br /&gt;
    k2=A*(y+(h/2)*k1);&lt;br /&gt;
    k3=A*(y+(h/2)*k2);&lt;br /&gt;
    k4=A*(y+h*k3);&lt;br /&gt;
    y=y+(h/6)*(k1+2*k2+2*k3+k4);&lt;br /&gt;
    y1(n+1)=y(1);&lt;br /&gt;
    y2(n+1)=y(2);&lt;br /&gt;
    y3(n+1)=y(3);&lt;br /&gt;
end&lt;br /&gt;
t=[t0:h:tN];&lt;br /&gt;
num=int8(100*(k-0.1+0.01));&lt;br /&gt;
%F2 has as rows approximations of y2 for the different values of k &lt;br /&gt;
F2(num,:)=y2;&lt;br /&gt;
end&lt;br /&gt;
t=[t0:h:tN];&lt;br /&gt;
k1=[0.1:0.01:1];&lt;br /&gt;
f20=F2(:,401);&lt;br /&gt;
f20=f20';&lt;br /&gt;
o=ones(1,91);&lt;br /&gt;
figure(1)&lt;br /&gt;
hold on&lt;br /&gt;
plot(k1,f20,'+')&lt;br /&gt;
plot(k1,o,'r')&lt;br /&gt;
xlabel('k')&lt;br /&gt;
ylabel('f´(20)')&lt;br /&gt;
legend('f´(20)','y=1')&lt;br /&gt;
hold off&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[Archivo: Graficaf'(20)RK.jpg|thumb|500px|left|Graph of &amp;lt;math&amp;gt;f’(20)&amp;lt;/math&amp;gt;  for each &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Resolution with Euler method==&lt;br /&gt;
Then is exposed the Matlab code that numerically that solves the Blasius equation for different values of &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; , with &amp;lt;math&amp;gt; k \in \mbox{(0,1;1)}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;dk=0,01&amp;lt;/math&amp;gt;   ,with &amp;lt;math&amp;gt; \eta \in \mbox{(0,20)}&amp;lt;/math&amp;gt; and with &amp;lt;math&amp;gt;h=0,05&amp;lt;/math&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
%Resolution of Blasius  equation(with Euler)&lt;br /&gt;
&lt;br /&gt;
clear all&lt;br /&gt;
t0=0;&lt;br /&gt;
tN=20;&lt;br /&gt;
h=0.05;&lt;br /&gt;
N=(tN-t0)/h;&lt;br /&gt;
F2=zeros(91,401);&lt;br /&gt;
for k=0.1:0.01:1&lt;br /&gt;
y=[0;0;k];&lt;br /&gt;
y1=y(1);&lt;br /&gt;
y2=y(2);&lt;br /&gt;
y3=y(3);&lt;br /&gt;
for n=1:N&lt;br /&gt;
    A=[0 1 0;0 0 1;(-y(3)/2) 0 0];&lt;br /&gt;
    y=y+h*A*y;&lt;br /&gt;
    y1(n+1)=y(1);&lt;br /&gt;
    y2(n+1)=y(2);&lt;br /&gt;
    y3(n+1)=y(3);&lt;br /&gt;
end&lt;br /&gt;
t=[t0:h:tN];&lt;br /&gt;
num=int8(100*(k-0.1+0.01));&lt;br /&gt;
%F2 has as rows approximations of y2 for the different values of k &lt;br /&gt;
F2(num,:)=y2;&lt;br /&gt;
end&lt;br /&gt;
t=[t0:h:tN];&lt;br /&gt;
k1=[0.1:0.01:1];&lt;br /&gt;
f20=F2(:,401);&lt;br /&gt;
f20=f20';&lt;br /&gt;
o=ones(1,91);&lt;br /&gt;
figure(1)&lt;br /&gt;
hold on&lt;br /&gt;
plot(k1,f20,'+')&lt;br /&gt;
plot(k1,o,'r')&lt;br /&gt;
xlabel('k')&lt;br /&gt;
ylabel('f´(20)')&lt;br /&gt;
legend('f´(20)','y=1')&lt;br /&gt;
hold off&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[Archivo: Graficaf'(20).jpg|thumb|500px|left|Graph of &amp;lt;math&amp;gt;f’(20)&amp;lt;/math&amp;gt;  for each &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;]]&lt;br /&gt;
|}&lt;br /&gt;
== Conclusion==&lt;br /&gt;
Comparing the graphs, we see that the difference between modified Euler and 4th order Runge Kutta methods is minimal and the value for each parameter is &amp;lt;math&amp;gt;k=0,33&amp;lt;/math&amp;gt; , on the other hand, by using the Euler method (less accurate than the above) the value of the parameter is &amp;lt;math&amp;gt;k=0,32&amp;lt;/math&amp;gt;, although graphically this difference is hardly seen.&lt;br /&gt;
&lt;br /&gt;
==Graph of &amp;lt;math&amp;gt;f´(\eta)&amp;lt;/math&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The graph of &amp;lt;math&amp;gt;f'(\eta)&amp;lt;/math&amp;gt;has been realized in &amp;lt;math&amp;gt;\eta \in \mbox {(0,20)}&amp;lt;/math&amp;gt; for the value of parameter &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; obtained in the modified Euler method, ie &amp;lt;math&amp;gt;k=0.33&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To get this graph we add into the modified Euler method, the following MATLAB code:&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
&lt;br /&gt;
%We plot f2 for k = 0.33 which is in row 24 of the matrix&lt;br /&gt;
f2=F2(24,:);&lt;br /&gt;
figure(2)&lt;br /&gt;
plot(t,f2,'*')&lt;br /&gt;
xlabel('\eta')&lt;br /&gt;
ylabel('f´(\eta)')&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| [[Archivo: Graficaf'eta.jpg|thumb|800px|left|Graph of &amp;lt;math&amp;gt;f´(\eta)&amp;lt;/math&amp;gt; for &amp;lt;math&amp;gt;k=0,33&amp;lt;/math&amp;gt; ]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As can be seen, if we run the full program and see the vector &amp;lt;math&amp;gt;f2&amp;lt;/math&amp;gt; the value of &amp;lt;math&amp;gt;\eta_0&amp;lt;/math&amp;gt; for which &amp;lt;math&amp;gt;\ \vert f'(\eta)-1 \vert &amp;lt; 0,01&amp;lt;/math&amp;gt; , if &amp;lt;math&amp;gt;\eta&amp;gt;\eta _0&amp;lt;/math&amp;gt;, is &amp;lt;math&amp;gt;\eta_0\ge5,95&amp;lt;/math&amp;gt; for &amp;lt;math&amp;gt; \eta \in \mbox{(0,20)}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Horizontal velocity of the fluid=&lt;br /&gt;
Once we have numerically calculated the &amp;lt;math&amp;gt;f( \eta)&amp;lt;/math&amp;gt; we proceed to calculate the horizontal component of the fluid velocity &amp;lt;math&amp;gt; u_1 &amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\vec{u}=(u_1,u_2)=(\frac{\partial \psi}{\partial y},-\frac{\partial \psi}{\partial x})&amp;lt;/math&amp;gt;  Thus, as defined above:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;u_1=\frac{\partial \psi}{\partial y}=\frac{\partial }{\partial y}(\sqrt[]{\nu u_0 x} f(\eta))= \sqrt[]{\nu u_0 x} \frac{\partial f(\eta)}{\partial y}=\sqrt[]{\nu u_0 x} \frac{\partial f(\eta)}{\partial \eta} \frac{\partial \eta}{\partial y}=\sqrt[]{\nu u_0 x} \sqrt[]{\frac{u_0}{\nu x}} f’(\eta)=u_0 f’(\eta)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To translate this result graphically we calculate &amp;lt;math&amp;gt;u_1(x_k,y)&amp;lt;/math&amp;gt; with the Modified Euler method where &amp;lt;math&amp;gt;x_k=0.05,0.2,0.4,0.6,0.8&amp;lt;/math&amp;gt;  and &amp;lt;math&amp;gt;y \in \mbox{(0,3)}&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;h=0.01&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
%We calculate u1 with the different values of xk(with modified Euler)&lt;br /&gt;
clear all&lt;br /&gt;
xk=[0.05,0.2,0.4,0.6,0.8];&lt;br /&gt;
nu=1; u0=2;&lt;br /&gt;
y0=0; yN=3; hy=0.01;&lt;br /&gt;
N=(yN-y0)/hy;&lt;br /&gt;
y=y0:hy:yN;&lt;br /&gt;
for m=1:5&lt;br /&gt;
%We define eta ('t') for each value of  xk, each one &lt;br /&gt;
%corresponding to a row, and with 'y' in (0,3)&lt;br /&gt;
t(m,:)=sqrt(u0/(nu*xk(m)))*y;&lt;br /&gt;
h=sqrt(u0/(nu*xk(m)))*0.01;&lt;br /&gt;
f0=[0;0;0.33];&lt;br /&gt;
f=[f0(1);f0(2);f0(3)];&lt;br /&gt;
for n=1:N&lt;br /&gt;
    A=[0 1 0;0 0 1;(-f0(3)/2) 0 0];&lt;br /&gt;
    z=f0+h*A*f0;&lt;br /&gt;
    f0=f0+(h/2)*(A*f0+A*z);&lt;br /&gt;
    f(:,n+1)=[f0(1);f0(2);f0(3)];&lt;br /&gt;
end&lt;br /&gt;
Y(m,:)=f(2,:);&lt;br /&gt;
end&lt;br /&gt;
F=u0*Y;&lt;br /&gt;
hold on&lt;br /&gt;
plot(y,F(1,:),'k')&lt;br /&gt;
plot(y,F(2,:))&lt;br /&gt;
plot(y,F(3,:),'r')&lt;br /&gt;
plot(y,F(4,:),'m')&lt;br /&gt;
plot(y,F(5,:),'g')&lt;br /&gt;
legend('u_{1} for x_{k}=0.05','u_{1} for x_{k}=0.2','u_{1} for x_{k}=0.4','u_{1} for x_{k}=0.6','u_{1} for x_{k}=0.8','location','best')&lt;br /&gt;
xlabel('y')&lt;br /&gt;
ylabel('u_{1}')&lt;br /&gt;
hold off&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Archivo:Ap4a.png|thumb|800px|centre|In this picture are shown &amp;lt;math&amp;gt;5&amp;lt;/math&amp;gt; graphs, each one corresponds to a different value of &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;. ]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
According to this graph we can appreciate that the fluid, when is moving along the &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; axis, has to achieve higher height to get limit velocity &amp;lt;math&amp;gt;u_0&amp;lt;/math&amp;gt;, i.e., when the fluid moves, it must be getting over the plate to offset the perturbation that the plate provokes to it ( to a higher value of &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; is greater the transition zone between zero velocity of the plate and the limit velocity &amp;lt;math&amp;gt;u_0&amp;lt;/math&amp;gt; with which the fluid initially starts).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Laminar boundary layer of the fluid =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
According to the above findings, it can be deduced that there is for each value of &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; a limit value  &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; from which the fluid velocity becomes constant speed again, with the same value that it had initially before reaching the area of the plate.&lt;br /&gt;
Obviously the value of the boundary layer will be related to the value &amp;lt;math&amp;gt;\eta_0&amp;lt;/math&amp;gt;, calculated above, for which the function &amp;lt;math&amp;gt;f’(\eta)&amp;lt;/math&amp;gt;  will become almost constant. The relationship is expressed as follows:&lt;br /&gt;
&amp;lt;math&amp;gt;\eta  = y  \sqrt[]{ \frac{u_0}{\nu x}}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;math&amp;gt;\eta=\eta_0&amp;lt;/math&amp;gt;, then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\eta_0=y  \sqrt[]{ \frac{2}{x}};  y=\frac{\eta_0\sqrt[]{x}}{\sqrt[]{2}}=g(x);&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Therefore we can interpret this function &amp;lt;math&amp;gt;g(x)&amp;lt;/math&amp;gt; as the fluid boundary layer. Simple Matlab code is exposed for its representation:&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
%plot function g(x)&lt;br /&gt;
x=[0:0.05:10];&lt;br /&gt;
eta0=5.95;&lt;br /&gt;
y=eta0*(x/2).^(1/2);&lt;br /&gt;
plot(x,y,'r')&lt;br /&gt;
xlabel('x')&lt;br /&gt;
ylabel('g(x)')&lt;br /&gt;
legend('g(x), interpreted as boundary layer','location','best')&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[Archivo: Figureg(x).jpg|thumb|500px|left|Graph of &amp;lt;math&amp;gt;g(x)&amp;lt;/math&amp;gt; ]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In view of the graph, the findings are similar to previous ones. As the value &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; increases, you need a higher value of &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; for the fluid velocity stabilizes and becomes the speed that we had initially.&lt;br /&gt;
&lt;br /&gt;
[[Categoría:Ecuaciones Diferenciales]]&lt;br /&gt;
[[Categoría:ED13/14]]&lt;br /&gt;
[[Categoría:Trabajos 2013-14]]&lt;/div&gt;</summary>
		<author><name>Marino Rivera</name></author>	</entry>

	<entry>
		<id>https://mat.caminos.upm.es/w/index.php?title=Boundary_layer_in_laminar_fluids_(Grupo_1B)&amp;diff=10666</id>
		<title>Boundary layer in laminar fluids (Grupo 1B)</title>
		<link rel="alternate" type="text/html" href="https://mat.caminos.upm.es/w/index.php?title=Boundary_layer_in_laminar_fluids_(Grupo_1B)&amp;diff=10666"/>
				<updated>2014-03-06T22:49:24Z</updated>
		
		<summary type="html">&lt;p&gt;Marino Rivera: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ TrabajoED |Boundary layer in laminar fluids. Grupo 1-B | [[:Categoría:Ecuaciones Diferenciales|Ecuaciones Diferenciales]]|[[:Categoría:ED13/14|Curso 2013-14]] | Sandro Andrés Martínez &lt;br /&gt;
 &lt;br /&gt;
David Ayala Díez &lt;br /&gt;
 &lt;br /&gt;
Claudia Cózar Coarasa  &lt;br /&gt;
&lt;br /&gt;
Lorena de la Fuente Sanz  &lt;br /&gt;
&lt;br /&gt;
Marino Rivera Muñoz &lt;br /&gt;
  &lt;br /&gt;
José Manuel Torres Serrano }}&lt;br /&gt;
&lt;br /&gt;
In this numerical project we have studied what happens when we introduce a flat plate in a laminar fluid whose speed and viscosity are constant.&lt;br /&gt;
&lt;br /&gt;
= Blasius equation =	&lt;br /&gt;
&lt;br /&gt;
First, we must assume that the fluid velocity before reaching the plate is constant, as in remote areas after passing the plate.&lt;br /&gt;
&lt;br /&gt;
In our case we take this constant as &amp;lt;math&amp;gt;2&amp;lt;/math&amp;gt;, such that&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\overrightarrow{u} =  u_0\cdot\overrightarrow{i}, u_0 = 2 &amp;lt;/math&amp;gt;&lt;br /&gt;
[[Archivo:Flujo.png|thumb|200px|left|Laminar fluid with velocity &amp;lt;math&amp;gt; u_0 &amp;lt;/math&amp;gt;]]&lt;br /&gt;
&lt;br /&gt;
Then, we must define the fluid stream function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\psi(x,y)  =  \sqrt[]{ \nu \cdot\ u_0 \cdot x} f(\eta)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where we take the viscosity &amp;lt;math&amp;gt; \nu &amp;lt;/math&amp;gt; as a unit value and&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\eta  = y  \sqrt[]{ \frac{u_0}{\nu x}}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt; f(\nu) &amp;lt;/math&amp;gt; Satisfies the Blasius equation, and therefore we will raise the initial value problem associated with this equation with the following initial conditions&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{cases}&lt;br /&gt;
f’’’(\eta)+\frac{1}{2}f(\eta)f’’(\eta)=0 ; \\&lt;br /&gt;
f(\eta)=f’(\eta)=0, \lim_{\eta \to \infty}f’(\eta)= 1 ;&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
However, on time of programming we cannot introduce a conditional limit, so we have to replace them by the condition &amp;lt;math&amp;gt; f’’(\eta)=k &amp;lt;/math&amp;gt;, and vary the values of k to find the one that satisfies the limit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We cannot solve the differential equation like such, to apply the numerical methods, we need to pass it to a system of equations:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
f(\eta)=y_1,f’(\eta)=y_2,f’’(\eta)=y_3\\&lt;br /&gt;
\begin{cases}&lt;br /&gt;
y_1’=y_2;\\&lt;br /&gt;
y_2’=y_3;\\&lt;br /&gt;
y_3’=-\frac{1}{2}y_1y_3;\\&lt;br /&gt;
y_1(0)=y_2(0)=0; y_3(0)=k&lt;br /&gt;
\end{cases}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once the system has been formulated , we start to solve it.&lt;br /&gt;
&lt;br /&gt;
== Resolution with the modified Euler method ==&lt;br /&gt;
Then is exposed the Matlab code that numerically that solves the Blasius equation for different values of &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; , with &amp;lt;math&amp;gt; k \in \mbox{(0,1;1)}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;dk=0,01&amp;lt;/math&amp;gt;   ,with &amp;lt;math&amp;gt; \eta \in \mbox{(0,20)}&amp;lt;/math&amp;gt; and with &amp;lt;math&amp;gt;h=0,05&amp;lt;/math&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
%Resolution of Blasius equation(with modified Euler)&lt;br /&gt;
clear all&lt;br /&gt;
%Initial conditions&lt;br /&gt;
t0=0;&lt;br /&gt;
tN=20;&lt;br /&gt;
h=0.05;&lt;br /&gt;
N=(tN-t0)/h;&lt;br /&gt;
F2=zeros(91,401);%We create the matrix F2 where we will store the different&lt;br /&gt;
%solutions of f2 for each value of k&lt;br /&gt;
for k=0.1:0.01:1&lt;br /&gt;
y=[0;0;k];&lt;br /&gt;
y1=y(1);&lt;br /&gt;
y2=y(2);&lt;br /&gt;
y3=y(3);&lt;br /&gt;
for n=1:N&lt;br /&gt;
    A=[0 1 0;0 0 1;(-y(3)/2) 0 0]; %To simplify and solve using matrices, we create&lt;br /&gt;
 %the matrix A in the loop with different values of f3&lt;br /&gt;
    z=y+h*A*y;&lt;br /&gt;
    y=y+(h/2)*(A*y+A*z);&lt;br /&gt;
    y1(n+1)=y(1);&lt;br /&gt;
    y2(n+1)=y(2);&lt;br /&gt;
    y3(n+1)=y(3);&lt;br /&gt;
end&lt;br /&gt;
t=[t0:h:tN];&lt;br /&gt;
num=int8(100*(k-0.1+0.01));&lt;br /&gt;
%F2 has as rows approximations of y2 for the different values of k&lt;br /&gt;
F2(num,:)=y2;&lt;br /&gt;
end&lt;br /&gt;
k1=[0.1:0.01:1]; %Vector to represent the values of f2 in 20&lt;br /&gt;
f20=F2(:,401);&lt;br /&gt;
f20=f20';&lt;br /&gt;
o=ones(1,91);%We represented f = 1 for better viewing&lt;br /&gt;
figure(1)&lt;br /&gt;
hold on&lt;br /&gt;
plot(k1,f20,'+')&lt;br /&gt;
plot(k1,o,'r') &lt;br /&gt;
xlabel('k')&lt;br /&gt;
ylabel('f´(20)')&lt;br /&gt;
legend('f´(20)','y=1')&lt;br /&gt;
hold off&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|[[Archivo:Graficaf'(20)M.jpg|thumb|500px|left|Graph of &amp;lt;math&amp;gt;f’(20)&amp;lt;/math&amp;gt;  for each &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; ]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
As noted in the graph the value for which the function is closer to &amp;lt;math&amp;gt;1&amp;lt;/math&amp;gt; is &amp;lt;math&amp;gt;k=0,33&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Resolution with 4th order Runge-Kutta method==&lt;br /&gt;
Then is exposed the Matlab code that numerically that solves the Blasius equation for different values of &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; , with &amp;lt;math&amp;gt; k \in \mbox{(0,1;1)}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;dk=0,01&amp;lt;/math&amp;gt;   ,with &amp;lt;math&amp;gt; \eta \in \mbox{(0,20)}&amp;lt;/math&amp;gt; and with &amp;lt;math&amp;gt;h=0,05&amp;lt;/math&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
% Resolution of Blasius  equation(with Runge-Kutta)&lt;br /&gt;
clear all&lt;br /&gt;
t0=0;&lt;br /&gt;
tN=20;&lt;br /&gt;
h=0.05;&lt;br /&gt;
N=(tN-t0)/h;&lt;br /&gt;
F2=zeros(91,401);&lt;br /&gt;
for k=0.1:0.01:1&lt;br /&gt;
y=[0;0;k];&lt;br /&gt;
y1=y(1);&lt;br /&gt;
y2=y(2);&lt;br /&gt;
y3=y(3);&lt;br /&gt;
for n=1:N&lt;br /&gt;
    A=[0 1 0;0 0 1;(-y(3)/2) 0 0];&lt;br /&gt;
    k1=A*y;&lt;br /&gt;
    k2=A*(y+(h/2)*k1);&lt;br /&gt;
    k3=A*(y+(h/2)*k2);&lt;br /&gt;
    k4=A*(y+h*k3);&lt;br /&gt;
    y=y+(h/6)*(k1+2*k2+2*k3+k4);&lt;br /&gt;
    y1(n+1)=y(1);&lt;br /&gt;
    y2(n+1)=y(2);&lt;br /&gt;
    y3(n+1)=y(3);&lt;br /&gt;
end&lt;br /&gt;
t=[t0:h:tN];&lt;br /&gt;
num=int8(100*(k-0.1+0.01));&lt;br /&gt;
%F2 has as rows approximations of y2 for the different values of k &lt;br /&gt;
F2(num,:)=y2;&lt;br /&gt;
end&lt;br /&gt;
t=[t0:h:tN];&lt;br /&gt;
k1=[0.1:0.01:1];&lt;br /&gt;
f20=F2(:,401);&lt;br /&gt;
f20=f20';&lt;br /&gt;
o=ones(1,91);&lt;br /&gt;
figure(1)&lt;br /&gt;
hold on&lt;br /&gt;
plot(k1,f20,'+')&lt;br /&gt;
plot(k1,o,'r')&lt;br /&gt;
xlabel('k')&lt;br /&gt;
ylabel('f´(20)')&lt;br /&gt;
legend('f´(20)','y=1')&lt;br /&gt;
hold off&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[Archivo: Graficaf'(20)RK.jpg|thumb|500px|left|Graph of &amp;lt;math&amp;gt;f’(20)&amp;lt;/math&amp;gt;  for each &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Resolution with Euler method==&lt;br /&gt;
Then is exposed the Matlab code that numerically that solves the Blasius equation for different values of &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; , with &amp;lt;math&amp;gt; k \in \mbox{(0,1;1)}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;dk=0,01&amp;lt;/math&amp;gt;   ,with &amp;lt;math&amp;gt; \eta \in \mbox{(0,20)}&amp;lt;/math&amp;gt; and with &amp;lt;math&amp;gt;h=0,05&amp;lt;/math&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
%Resolution of Blasius  equation(with Euler)&lt;br /&gt;
&lt;br /&gt;
clear all&lt;br /&gt;
t0=0;&lt;br /&gt;
tN=20;&lt;br /&gt;
h=0.05;&lt;br /&gt;
N=(tN-t0)/h;&lt;br /&gt;
F2=zeros(91,401);&lt;br /&gt;
for k=0.1:0.01:1&lt;br /&gt;
y=[0;0;k];&lt;br /&gt;
y1=y(1);&lt;br /&gt;
y2=y(2);&lt;br /&gt;
y3=y(3);&lt;br /&gt;
for n=1:N&lt;br /&gt;
    A=[0 1 0;0 0 1;(-y(3)/2) 0 0];&lt;br /&gt;
    y=y+h*A*y;&lt;br /&gt;
    y1(n+1)=y(1);&lt;br /&gt;
    y2(n+1)=y(2);&lt;br /&gt;
    y3(n+1)=y(3);&lt;br /&gt;
end&lt;br /&gt;
t=[t0:h:tN];&lt;br /&gt;
num=int8(100*(k-0.1+0.01));&lt;br /&gt;
%F2 has as rows approximations of y2 for the different values of k &lt;br /&gt;
F2(num,:)=y2;&lt;br /&gt;
end&lt;br /&gt;
t=[t0:h:tN];&lt;br /&gt;
k1=[0.1:0.01:1];&lt;br /&gt;
f20=F2(:,401);&lt;br /&gt;
f20=f20';&lt;br /&gt;
o=ones(1,91);&lt;br /&gt;
figure(1)&lt;br /&gt;
hold on&lt;br /&gt;
plot(k1,f20,'+')&lt;br /&gt;
plot(k1,o,'r')&lt;br /&gt;
xlabel('k')&lt;br /&gt;
ylabel('f´(20)')&lt;br /&gt;
legend('f´(20)','y=1')&lt;br /&gt;
hold off&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[Archivo: Graficaf'(20).jpg|thumb|500px|left|Graph of &amp;lt;math&amp;gt;f’(20)&amp;lt;/math&amp;gt;  for each &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;]]&lt;br /&gt;
|}&lt;br /&gt;
== Conclusion==&lt;br /&gt;
Comparing the graphs, we see that the difference between modified Euler and 4th order Runge Kutta methods is minimal and the value for each parameter is &amp;lt;math&amp;gt;k=0,33&amp;lt;/math&amp;gt; , on the other hand, by using the Euler method (less accurate than the above) the value of the parameter is &amp;lt;math&amp;gt;k=0,32&amp;lt;/math&amp;gt;, although graphically this difference is hardly seen.&lt;br /&gt;
&lt;br /&gt;
==Graph of &amp;lt;math&amp;gt;f´(\eta)&amp;lt;/math&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The graph of &amp;lt;math&amp;gt;f'(\eta)&amp;lt;/math&amp;gt;has been realized in &amp;lt;math&amp;gt;\eta \in \mbox {(0,20)}&amp;lt;/math&amp;gt; for the value of parameter &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; obtained in the modified Euler method, ie &amp;lt;math&amp;gt;k=0.33&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To get this graph we add into the modified Euler method, the following MATLAB code:&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
&lt;br /&gt;
%We plot f2 for k = 0.33 which is in row 24 of the matrix&lt;br /&gt;
f2=F2(24,:);&lt;br /&gt;
figure(2)&lt;br /&gt;
plot(t,f2,'*')&lt;br /&gt;
xlabel('\eta')&lt;br /&gt;
ylabel('f´(\eta)')&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| [[Archivo: Graficaf'eta.jpg|thumb|800px|left|Graph of &amp;lt;math&amp;gt;f´(\eta)&amp;lt;/math&amp;gt; for &amp;lt;math&amp;gt;k=0,33&amp;lt;/math&amp;gt; ]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As can be seen, if we run the full program and see the vector &amp;lt;math&amp;gt;f2&amp;lt;/math&amp;gt; the value of &amp;lt;math&amp;gt;\eta_0&amp;lt;/math&amp;gt; for which &amp;lt;math&amp;gt;\ \vert f'(\eta)-1 \vert &amp;lt; 0,01&amp;lt;/math&amp;gt; , if &amp;lt;math&amp;gt;\eta&amp;gt;\eta _0&amp;lt;/math&amp;gt;, is &amp;lt;math&amp;gt;\eta_0\ge5,95&amp;lt;/math&amp;gt; for &amp;lt;math&amp;gt; \eta \in \mbox{(0,20)}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Horizontal velocity of the fluid=&lt;br /&gt;
Once we have numerically calculated the &amp;lt;math&amp;gt;f( \eta)&amp;lt;/math&amp;gt; we proceed to calculate the horizontal component of the fluid velocity &amp;lt;math&amp;gt; u_1 &amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\vec{u}=(u_1,u_2)=(\frac{\partial \psi}{\partial y},-\frac{\partial \psi}{\partial x})&amp;lt;/math&amp;gt;  Thus, as defined above:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;u_1=\frac{\partial \psi}{\partial y}=\frac{\partial }{\partial y}(\sqrt[]{\nu u_0 x} f(\eta))= \sqrt[]{\nu u_0 x} \frac{\partial f(\eta)}{\partial y}=\sqrt[]{\nu u_0 x} \frac{\partial f(\eta)}{\partial \eta} \frac{\partial \eta}{\partial y}=\sqrt[]{\nu u_0 x} \sqrt[]{\frac{u_0}{\nu x}} f’(\eta)=u_0 f’(\eta)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To translate this result graphically we calculate &amp;lt;math&amp;gt;u_1(x_k,y)&amp;lt;/math&amp;gt; with the Modified Euler method where &amp;lt;math&amp;gt;x_k=0.05,0.2,0.4,0.6,0.8&amp;lt;/math&amp;gt;  and &amp;lt;math&amp;gt;y \in \mbox{(0,3)}&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;h=0.01&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
%We calculate u1 with the different values of xk(with modified Euler)&lt;br /&gt;
clear all&lt;br /&gt;
xk=[0.05,0.2,0.4,0.6,0.8];&lt;br /&gt;
nu=1; u0=2;&lt;br /&gt;
y0=0; yN=3; hy=0.01;&lt;br /&gt;
N=(yN-y0)/hy;&lt;br /&gt;
y=y0:hy:yN;&lt;br /&gt;
for m=1:5&lt;br /&gt;
%We define eta ('t') for each value of  xk, each one &lt;br /&gt;
%corresponding to a row, and with 'y' in (0,3)&lt;br /&gt;
t(m,:)=sqrt(u0/(nu*xk(m)))*y;&lt;br /&gt;
h=sqrt(u0/(nu*xk(m)))*0.01;&lt;br /&gt;
f0=[0;0;0.33];&lt;br /&gt;
f=[f0(1);f0(2);f0(3)];&lt;br /&gt;
for n=1:N&lt;br /&gt;
    A=[0 1 0;0 0 1;(-f0(3)/2) 0 0];&lt;br /&gt;
    z=f0+h*A*f0;&lt;br /&gt;
    f0=f0+(h/2)*(A*f0+A*z);&lt;br /&gt;
    f(:,n+1)=[f0(1);f0(2);f0(3)];&lt;br /&gt;
end&lt;br /&gt;
Y(m,:)=f(2,:);&lt;br /&gt;
end&lt;br /&gt;
F=u0*Y;&lt;br /&gt;
hold on&lt;br /&gt;
plot(y,F(1,:),'k')&lt;br /&gt;
plot(y,F(2,:))&lt;br /&gt;
plot(y,F(3,:),'r')&lt;br /&gt;
plot(y,F(4,:),'m')&lt;br /&gt;
plot(y,F(5,:),'g')&lt;br /&gt;
legend('u_{1} for x_{k}=0.05','u_{1} for x_{k}=0.2','u_{1} for x_{k}=0.4','u_{1} for x_{k}=0.6','u_{1} for x_{k}=0.8','location','best')&lt;br /&gt;
xlabel('y')&lt;br /&gt;
ylabel('u_{1}')&lt;br /&gt;
hold off&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Archivo:Ap4a.png|thumb|800px|centre|In this picture are shown &amp;lt;math&amp;gt;5&amp;lt;/math&amp;gt; graphs, each one corresponds to a different value of &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;. ]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
According to this graph we can appreciate that the fluid, when is moving along the &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; axis, has to achieve higher height to get limit velocity &amp;lt;math&amp;gt;u_0&amp;lt;/math&amp;gt;, i.e., when the fluid moves, it must be getting over the plate to offset the perturbation that the plate provokes to it ( to a higher value of &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; is greater the transition zone between zero velocity of the plate and the limit velocity &amp;lt;math&amp;gt;u_0&amp;lt;/math&amp;gt; with which the fluid initially starts).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Laminar boundary layer of the fluid =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
According to the above findings, it can be deduced that there is for each value of &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; a limit value  &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; from which the fluid velocity becomes constant speed again, with the same value that it had initially before reaching the area of the plate.&lt;br /&gt;
Obviously the value of the boundary layer will be related to the value &amp;lt;math&amp;gt;\eta_0&amp;lt;/math&amp;gt;, calculated above, for which the function &amp;lt;math&amp;gt;f’(\eta)&amp;lt;/math&amp;gt;  will become almost constant. The relationship is expressed as follows:&lt;br /&gt;
&amp;lt;math&amp;gt;\eta  = y  \sqrt[]{ \frac{u_0}{\nu x}}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;math&amp;gt;\eta=\eta_0&amp;lt;/math&amp;gt;, then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\eta_0=y  \sqrt[]{ \frac{2}{x}};  y=\frac{\eta_0\sqrt[]{x}}{\sqrt[]{2}}=g(x);&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Therefore we can interpret this function &amp;lt;math&amp;gt;g(x)&amp;lt;/math&amp;gt; as the fluid boundary layer. Simple Matlab code is exposed for its representation:&lt;br /&gt;
&lt;br /&gt;
{{matlab|codigo=&lt;br /&gt;
%plot function g(x)&lt;br /&gt;
x=[0:0.05:10];&lt;br /&gt;
eta0=5.95;&lt;br /&gt;
y=eta0*(x/2).^(1/2);&lt;br /&gt;
plot(x,y,'r')&lt;br /&gt;
xlabel('x')&lt;br /&gt;
ylabel('g(x)')&lt;br /&gt;
legend('g(x), interpreted as boundary layer','location','best')&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[Archivo: Figureg(x).jpg|thumb|500px|left|Graph of &amp;lt;math&amp;gt;g(x)&amp;lt;/math&amp;gt; ]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In view of the graph, the findings are similar to previous ones. As the value &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; increases, you need a higher value of &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; for the fluid velocity stabilizes and becomes the speed that we had initially.&lt;br /&gt;
&lt;br /&gt;
[[Categoría:Ecuaciones Diferenciales]]&lt;br /&gt;
[[Categoría:ED13/14]]&lt;br /&gt;
[[Categoría:Trabajos 2013-14]]&lt;/div&gt;</summary>
		<author><name>Marino Rivera</name></author>	</entry>

	<entry>
		<id>https://mat.caminos.upm.es/w/index.php?title=Archivo:Ap4b.png&amp;diff=8714</id>
		<title>Archivo:Ap4b.png</title>
		<link rel="alternate" type="text/html" href="https://mat.caminos.upm.es/w/index.php?title=Archivo:Ap4b.png&amp;diff=8714"/>
				<updated>2014-02-26T23:01:12Z</updated>
		
		<summary type="html">&lt;p&gt;Marino Rivera: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Marino Rivera</name></author>	</entry>

	<entry>
		<id>https://mat.caminos.upm.es/w/index.php?title=Archivo:Ap4a.png&amp;diff=8713</id>
		<title>Archivo:Ap4a.png</title>
		<link rel="alternate" type="text/html" href="https://mat.caminos.upm.es/w/index.php?title=Archivo:Ap4a.png&amp;diff=8713"/>
				<updated>2014-02-26T23:00:19Z</updated>
		
		<summary type="html">&lt;p&gt;Marino Rivera: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Marino Rivera</name></author>	</entry>

	</feed>