Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:


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[[1]]

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[[1]]

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;


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.


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);

clear all;
Tw = 250;

Tam = 27;





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)


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


share|improve this question
@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 ? – CanYusuf Feb 4 '14 at 23:22
You're probably copying formatted equations. Try right click > copy as > input text. – R. M. 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 – CanYusuf Feb 5 '14 at 6:50
Your first code sample doesn't work? It is solvable in v8.0.4. – xzczd Feb 5 '14 at 9:44
@xzczd Oh I do not know, I have version 5.2 – CanYusuf Feb 5 '14 at 9:47
up vote 3 down vote accepted

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[[1]]
share|improve this answer
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 ? – CanYusuf 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. – xzczd Feb 5 '14 at 9:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.