# Integration resulting in imaginary result while solving a boundary value problem

I am trying to solve a boundary value problem involving a three-dimensional Laplacian $$\nabla^2T(x,y,z)=0$$ on the domain $$x\in[0,L], y\in[0,l], z\in[0,w]$$. I have six boundary conditions and based on 4 of them (in the $$x$$ and $$y$$ directions) I have the following solution form:

$$T(x,y,z)=\sum_{n,m=1}^{\infty}(C_1 e^{\gamma z}+C_1 e^{-\gamma z})\sin(\frac{\alpha_n x}{L}+\beta_n)\sin(\frac{\delta_m x}{L}+\theta_m)\tag 1$$

To determine the constant s $$C_1$$ and $$C_2$$ I have the following boundary conditions

$$\frac{\partial T(x,y,0)}{\partial z}=p_c(T(x,y,0)-t_c(x,y))\tag 2$$ $$\frac{\partial T(x,y,w)}{\partial z}=p_h(t_h(x,y)-T(x,y,w))\tag 3$$

where

$$t_c(x,y)=e^{\frac{-b_c y}{l}}\bigg(t_{ci}+\frac{b_c}{l}\int_0^y e^{\frac{b_c s}{l}} T(x,s,0)\mathrm{d}s\bigg)\tag4$$ $$t_h(x,y)=e^{\frac{-b_h x}{L}}\bigg(t_{hi}+\frac{b_h}{L}\int_0^x e^{\frac{b_h s}{L}} T(s,y,w)\mathrm{d}s\bigg)\tag5$$

$$p_h,p_c,t_{ci},t_{hi},b_c,b_h$$ are all constants. Also, I have already proven the orthogonality of $$\sin(\frac{\alpha_n x}{L}+\beta_n)$$ and $$\sin(\frac{\delta_m x}{L}+\theta_m)$$ for this particular problem.

My strategy is to substitute the solution form $$(1)$$ in each b.c $$(2)$$ and $$(3)$$. After substitution in lets say $$(2)$$, I multiply both sides by $$\sin(\frac{\alpha_n x}{L}+\beta_n)$$ and$$\sin(\frac{\delta_m x}{L}+\theta_m)$$ and integrate over the $$x$$ and $$y$$ domain to get a equation in $$C_1$$ and $$C_2$$.

On repeating the same procedure with b.c. $$(3)$$, I should get another equation which when solved with the previous should give $$C_1, C_2$$

The mathematica code to this end (till bc (2)) is

T[x_, y_, z_] = (Subscript[C, 1]*E^(γ*z) + Subscript[C, 2]/E^(γ*z))*
Sin[α*(x/L) + β]*Sin[δ*(y/l) + θ]

tc[x_, y_] = E^(-Subscript[β, c] y/l)*{tci + (Subscript[β, c]/l)*Integrate[E^(Subscript[β, c] s/l)*T[x, s, 0], {s, 0, y}]}

tc[x_, y_] = tc[x, y][[1]]

bc1 = (D[T[x, y, z], z] /. z -> 0) == Subscript[p, c] (T[x, y, 0] - tc[x, y])

ortheq1 = Integrate[bc1[[1]]*Sin[(α x/L) + β]*Sin[(δ y/l) + θ], {x, 0, L}, {y, 0, l}] == Integrate[bc1[[2]]*Sin[(α x/L) + β]*Sin[(δ y/l) + θ], {x, 0, L}, {y, 0, l},]


While doing the integral in the final step ortheq1 The integral on the RHS returns imaginary quantity. On searching Mathematica SE I found Why this real integral yields imaginary results? answer which uses the argument PrincipalValue -> True inside the Integrate expression to get rid of the complex problem. I too succeed in getting rid of it.

But I am unsure whether this would be the correct thing to do, and I am not missing anything vital here. Furthermore, is there an alternative workaround to this problem ?

NOTE: I leave the summations from my code to incorporate it later.

• The only complex numbers I see in executing your code are multiplications of complex conjugates in the denominators. Simplifying, got rid of the complex numbers for me. – Bill Watts May 10 at 1:24
• You should get rid of the trailing comma, so you don't get a Null in your result. – Bill Watts May 10 at 1:25
• @BillWatts If I am correct, you mean to say I should simplify the expression obtained after substitution of $T(x,y,z)$ in bc1 ? – Indrasis Mitra May 10 at 2:45
• Simplify ortheq1 after executing. – Bill Watts May 10 at 3:22
• Thanks Bill, this worked out perfectly. – Indrasis Mitra May 10 at 4:08