# A Understanding dummy variable in solution of 1D heat equation

Tags:
1. Nov 3, 2017

### Atr cheema

The solution of 1D diffusion equation on a half line (semi infinite) can be found with the help of Fourier Cosine Transform. Equation 3 is the attached figure is the solution of 1D diffusion equation (eq:1). I want to write a code for this equation in MATLAB/Python but I don't understand what value should I give for the dumy variable 'tau' .

This variable is not defined at the start and only appears during solution process.

2. Nov 3, 2017

### Orodruin

Staff Emeritus
You should not give it a value. It should be integrated from 0 to t.

3. Nov 3, 2017

### Atr cheema

Can you please elaborate that how this will be implemented in the form of a code (in MATLAB or any other language). I am sorry I am still confused!!.

4. Nov 7, 2017

### Atr cheema

I have implemented it in MATLAB with following code
Code (Text):
p = 100;      % number of steps
ft1 =   sin(linspace(0,45,p));
D = 100; x = 40;
t = 1:100;
ft2 = ft1*0.5;
ftau = -(ft2-ft1)/10 ;                                                           %   dh/dx
out_of_integral = sqrt(D/pi);
fun = @(tau,ftau,t) ftau./(t-tau).*exp(-x^2./(4*D*(t-tau)));
h = zeros(1,p);
for i = 1:p
q = integral(@(tau)fun(tau,ftau(i),t(i)),0,t(i));
h(i) = q*out_of_integral;
end
plot(ft1)
hold on;
plot(ft2,'k')
plot(ftau,'c')
plot(h,'r')
legend('Input','','f( \tau)','Output (observed)')
xlabel('time(sec) at x = 40m')
ylabel('temperature')
But the result is little problematic i:e amplitude of observed signal at x=40 keeps on increasing with time. The input data (f(tau)) is not totally realistic but I am unable to understand this increase in observed amplitude. The result can be seen in this figure.

5. Nov 7, 2017

### Orodruin

Staff Emeritus
In your function fun, ftau does not depend on tau...
What is the function $f(t)$ that you are trying to use?

6. Nov 7, 2017

### Atr cheema

If you look at equation 2 in figure attached in question, $f(t)$ is the change in $h$ at $x=0$. I am assuming $h(x=0,t)$ to be a sine wave and $f(t)$ as change in $h$ with respect to $x$. In the code $ft1$ represents $h(x=0,t)$.

7. Nov 7, 2017

### Orodruin

Staff Emeritus
No it doesn’t. You need to be much more careful with what you put in your script. And still that does not solve the fact that your ftau actually does not depend on tau in your integral.

I suggest going through every line of your code and consider if it is really doing what you want it to do or not.

Also note that you cannot assume $h(0,t)$ to have a particular form. The boundary condition at $x=0$ is a Neumann condition.