# Green's Function in Mathematica

The equation I am trying to solve is:

$$q \, T_1''(x)-T_1(x)(f-b \, g+i\,w \, p)=T(f_1-b \, g_1)-g_1\tag{1}$$

My professor says that $(1)$ can be solved by using Green's function $G(x,y)$, where $G(x,y)$ is the solution of this equation:

$$q\,G''(x,y)-G(x,y)\,(f-b\,g+i\,w\,p)=\mathrm{Dirac}(x-y)\tag{2}$$

The boundary conditions are:

$$G(L/2,y)=0 , G(-L/2,y)=0\tag{3}$$

And I tried to solve $(2)$:

eq1 = D[g[y], {y, 2}] - a*g[y] - DiracDelta[x - y]
ans1 = DSolve[{eq1 == 0, g[-L] == 0, g[L] == 0}, g[y], y]
greenfunction1 = g[y] /. ans1[]


But it does not work. However when I take out the constant $a$, it works:

eq1 = D[g[y], {y, 2}] - g[y] - DiracDelta[x - y]
ans1 = DSolve[{eq1 == 0, g[-L] == 0, g[L] == 0}, g[y], y]
greenfunction1 = g[y] /. ans1[]


Why does Mathematica fail to evaluate my first query?

Also, when I get the Green's function, I have to into solution of equation (1)which is;

Integrate[(T[y](f_1-bg_1)-g_1)g[y],{y,-L/.2,L/.2}]


where T(x) is;

T(x)= 2*C1*cosh(x*((f_0-b*g_0)/q)^0.5)+g/(f_0-b*g_0) (4)

Then C1 has to be determined from boundary condition.

T(+L/2)=0 T(-L/2)=0

The g_zero has to be determined from constant temperature condtion.

1/L*integral[T(x),{x-L/2,L/2}]=Tw-Tam

Then I found T(x) in Matlab. When I tried to solve Green Function part, I could not do it in Matlab. I deceided to move Mathematica. Now I want to solve all parts in Mathematica.

This is my Matlab code for T(x);

clc;
clear all;
Tw = 250;

Tam = 27;

resist=5.6e-8;

diameter=5e-6;

h=5700;

k=190;

f = pi()*diameter*h;

b = 0.0044;

q = 0.25*pi()*k*diameter^2;

L = 1.25e-3;

syms c x g

T = 2*c*cosh(x*((f-b*g)/q)^0.5)+g/(f-b*q);

c = solve(subs(T,'x',L/2)==0,c)

z = simplify(int(subs(T,'c',c),x,-L/2,L/2))

g = solve(z==L*(Tw-Tam),g)

T


I want to solve T and T_1 in Mathematica. Above I tried to solve Green Function code , but I could not put Green function and T into integration of T_1.

Sorry about text writing. I tried a lots of time copying from Mathematica , however its format did not match with here.

Thank you

Yusuf

• @rm -rf I try to edit my question by adding some equations from Mathematica. But When I copy from there, its format does not match with here. How can I do that ? Feb 4 '14 at 23:22
• You're probably copying formatted equations. Try right click > copy as > input text.
– rm -rf
Feb 4 '14 at 23:30
• Selections are plain text, formatted text, text(add whitespace), MathML, Cell Expression, Notebook Expression, Complete Notebook. And none of them looks like above equations which are editted by @Sektor Feb 5 '14 at 6:50
• Your first code sample doesn't work? It is solvable in v8.0.4. Feb 5 '14 at 9:44
• @xzczd Oh I do not know, I have version 5.2 Feb 5 '14 at 9:47

You just need to assume a is real:

eq1 = D[g[y], {y, 2}] - a g[y] - DiracDelta[x - y]
ans1 = Assuming[a \[Element] Reals, DSolve[{eq1 == 0, g[-L] == 0, g[L] == 0}, g[y], y]]
greenfunction1 = g[y] /. ans1[]

• Thank you for answer. But , as it can be seen in my equation (2), a equals to (f-bg+iwp), so it has "iwp" imaginary part. does it work assuming a is real ? Feb 5 '14 at 9:09
• Er… Just to confirm, DSolve won't work without Assuming in this case? Are you in v9? In v8.0.4, the Assuming isn't needed. Feb 5 '14 at 9:49

As of V10.4 GreenFunction is built in:

GreenFunction[{g''[y] - a g[y], g[-L] == 0, g[L] == 0}, g[y], {y, -L, L}, x] // TeXForm


$$\frac{\left(e^{2 \sqrt{a}\, x}-e^{2 \sqrt{a}\, L}\right) \left(e^{2 \sqrt{a}\, (L+y)}-1\right) \text{csch}\left(2 \sqrt{a}\, L\right) \theta (x-y) e^{-\sqrt{a}\, (2 L+x+y)}}{4 \sqrt{a}\,} \\ \quad\quad+\frac{\left(e^{2 \sqrt{a}\, (L+x)}-1\right) \left(e^{2 \sqrt{a}\, y}-e^{2 \sqrt{a}\, L}\right) \text{csch}\left(2 \sqrt{a}\, L\right) \theta (y-x) e^{-\sqrt{a}\, (2 L+x+y)}}{4 \sqrt{a}\,}$$