# Solving a Heat Equation with Neumann Boundary Conditions and an initial condition [closed]

i have this partial equation (heat equation) with the initial condition and the Neumann boundary conditions

Consider the heat equation: $$u_t(x, t)=u_{x x}(x, t)$$ where $$00$$ Neumann Boundary condition: $$\begin{array}{ll} u_x(0, t)=u, & t>0 \end{array}$$ $$\begin{array}{ll} u_x(1, t)=-u, & t>0 \end{array}$$ Initial condition: $$u(x, 0)=1, \quad 0 To solve the heat equation analytically with Neumann boundary conditions and an initial condition, we can use separation of variables. I got this result

$$u(x,t)=4 \sum_{n=1}^{\infty}\left[\frac{\sec \alpha_n}{\left(3+4 \alpha_n^2\right)} e^ {-\alpha_n^2 t} \cos 2 \alpha_n(x-0.5)\right], \quad(0

and I would like to implement this analytical solution with Excel-VBA, but the results are still different and the values are different, i.e.

my analytical solution is not correct, can someone help me to find the right analytical solution?

the correct values with the analytical solution should look like in the table shown correct values

• $u_{x}(0, t) = u$ doesn't make sense, similarly for the other boundary condition; the LHS is independent of $x$, the RHS dependent. Commented Feb 26, 2023 at 4:54
• I solved it numerically using the explicit finite difference method with the same boundary conditions and initial condition. but I can't get the right analytical solution? i.e. the values in the analytical solution that I received do not match the values in the tables above. did you try it too? why could the boundary conditions $\begin{array}{ll}u_x(0, t)=u, & t>0 \\ u_x(1, t)=-u, & t>0\end{array}$ Does not make any sense ? can you do more detail? Commented Feb 26, 2023 at 11:17
• The left hand side of each condition is independent of $x$ but the right hand side $u = u(x, t)$ is dependent on $x$. That doesn't make sense. Not only that, you can see your solution doesn't satisfy the following boundary condition $$u_{x}(0, t) = 4 \sum_{n \ge 1} \frac{2 \alpha_{n} \sec \alpha_{n}}{(3 + 4 \alpha_{n})^{2}} e^{- \alpha_{n}^{2} t} \sin \alpha_{n} \ne u(x, t)$$ and similarly for the other boundary condition. Commented Feb 26, 2023 at 11:49
• Yes, I noticed that my analytical solution does not satisfy the boundary condition for both The left hand side at x=0 and the right hand side at x=1, but the question is, do you think the neumann boundary conditions are wrong or not adjusted , they can't be u or -u ? or is it because of my analytical solution which is wrong? Commented Feb 26, 2023 at 12:26
• The boundary conditions don't make sense (as I've stated twice before). Commented Feb 26, 2023 at 12:56

can anyone check if my analytical solution is right and correct? $$u_t(x, t)=u_{x x}(x, t)$$ The general solution of the heat equation is given by $$u(x, t)=\frac{1}{\sqrt{4 \pi t}} \int_{-\infty}^{\infty} e^{-\frac{(x-y)^2}{4 t}} u(y, 0) d y$$ where $$u(y, 0)$$ is the initial condition. Now, let's substitute the given initial condition into the general solution $$u(x, t)=\frac{1}{\sqrt{4 \pi t}} \int_{-\infty}^{\infty} e^{-\frac{(x-y)^2}{4 t}} d y$$ We can simplify the integral by using the change of variable $$z=\frac{(x-y)^2}{4 t}$$ $$u(x, t)=\frac{1}{\sqrt{\pi}} \int_{-\infty}^{\infty} e^{-z^2} d z=1$$ Thus, the solution to the heat equation with the given initial condition is $$u(x,t) = 1$$. Now, let's apply the given Neumann boundary conditions to find the final solution. We start with the solution we derived earlier, $$u(x, t)=1$$ and differentiate it with respect to $$x$$ to obtain $$u_x(x, t)=0$$ Using the first Neumann boundary condition $$u_x(0, t) = u$$, we have $$u=u_x(0, t)=0$$ which implies that the constant $$u$$ is zero. Similarly, using the second Neumann boundary condition $$u_x(1, t) = -u$$, we get $$-u=u_x(1, t)=0$$ which again implies that the constant $$u$$ is zero. Therefore, the final solution to the heat equation with the given Neumann boundary conditions and initial condition is $$u(x, t)=1$$
This means that the temperature in the interval $$0 does not change with time and remains at a constant value of 1. Yes, that's correct. The Neumann boundary conditions specify the normal derivative of the solution at the boundaries of the domain. In the case of the given Neumann boundary conditions, the normal derivative of the solution at $$x=0$$ is a constant $$u$$ and the normal derivative of the solution at $$x=1$$ is the negative of that constant $$u$$. This means that the solution changes linearly along the boundaries, with a slope of $$u$$ at $$x=0$$ and a slope of $$-u$$ at $$x=1$$.
On the other hand, the initial condition specifies the value of the solution at the initial time $$t=0$$ for all points in the domain $$0. In this case, the initial condition is a constant function equal to 1. Therefore, the solution remains constant at 1 for all times $$t>0$$, independent of $$x$$. You're also correct that the left-hand side of the heat equation is independent of $$x$$, while the right-hand side is dependent on $$x$$. This reflects the fact that the heat equation describes the diffusion of heat in a one-dimensional medium, with heat flowing from regions of higher temperature to regions of lower temperature. The diffusion process depends on the temperature gradient, which is described by the second derivative of the solution with respect to $$x$$.