I need a function $T(x)$ thats needs to satisfy these Boundary Conditions (BC): Suppose that the B.C.s are such that at $x = 0$ the temperature is prescribed to be 20°C and the end x = L is insulated (i.e. the heat flux at this point is prescribed to be zero).
In other words $T(0)=20$ and $q=-k\frac{dT}{dx}|_{x=L}=0$
I tried the function $T(x)=20cos(\frac{\pi*x}{L})$, this function satisfy both BC, but I was told it was wrong, because the B.C. at x=0 is nonhomogeneous and my method is for homogeneous B.C. When the problem has nonhomogeneous B.C.’s, you have to do something else. One method is using a change of variables and turn the B.C.’s into homogeneous form I was told.
How do I turn the B.C. into homogeneous form? And find the function T(x) ?
I think the function $T(x)$ that I am after should be a polynomial, but not 100% sure.
Here is the full task, I know what to do next just need a correct trial function T(x) to complete the task task
You are correct.
The original DE is:
$$k\frac{\mathrm{d}}{\mathrm{d}x}\Big(\frac{\mathrm{d}T}{\mathrm{d}x}\Big)+Q=0$$ Substitute: $$U=\frac{\mathrm{d}T}{\mathrm{d}x}\implies \frac{\mathrm{d}}{\mathrm{d}x}\Big(\frac{\mathrm{d}T}{\mathrm{d}x}\Big)=U'$$ So that: $$kU'+Q=0$$ $$k\mathrm{d}U=-Q\mathrm{d}x$$ $$kU=-Qx+c_1$$ $$k\frac{\mathrm{d}T}{\mathrm{d}x}=-Qx+c_1$$ $$k\mathrm{d}T=(-Qx+c_1)\mathrm{d}x$$ $$kT=-\frac12 Qx^2+c_1x+c_2$$ With the first BC: $$T(0)=20\implies k20=c_2\implies \boxed{c_2=20k}$$ With: $$T=\frac{1}{k}\big(-\frac12 Qx^2+c_1x+c_2\big)$$ $$\frac{\mathrm{d}T}{\mathrm{d}x}=\frac{1}{k}(-Qx+c_1)$$ Second boundary condition: $$-k\Big(\frac{\mathrm{d}T}{\mathrm{d}x}\Big)_{x=L}=-(-QL+c_1)=0$$ $$\implies \boxed{c_1=QL}$$ So we have:
$$\boxed{T(x)=\frac1k\Big(-\frac12 Qx^2+QLx+20k\Big)}$$