I am beginner in Mathematica. My goal is to calculate an integral of the following Complex function, \begin{equation}\nonumber f(y)=\frac{1}{2\pi} \times\frac{\sqrt{3}a\cosh(0.4)\cos(ca/2)\cos{(\sqrt{3}ay/2)}+2\sqrt{3}a\cos^{2}(ca/2)-i\sqrt{3}a\sinh(0.4)\cos{(ca/2)}\sin(\sqrt{3}ay/2)}{1+4\cos^{2}(ca/2)+4\cosh(0.4)\cos(ca/2)\cos(\sqrt{3}ay/2)-4i\sinh(0.4)\cos(ca/2)\sin(\sqrt{3}ay/2)} \end{equation} on the range $y\in\frac{2\pi}{a\sqrt{3}}(-1,1)$, with the conditions $a>0$ and $1.45779\leq c\leq 2.45804$. Here $c$ is a fixed parameter although it is in the interval above. I know the expected response is $1/2$ but when I try to do it in mathematica, it only keeps the message "running ..." and does not complete the calculation. How can I solve this problem? Thank you in advance.

  • $\begingroup$ Can you provide code? $\endgroup$ – Kuba Feb 28 '18 at 20:06
  • $\begingroup$ The input should be provided in cut-and-pastable form. $\endgroup$ – Mariusz Iwaniuk Feb 28 '18 at 20:08
  • $\begingroup$ I'm sorry, the code it is, g[y_]:=(Sqrt[3] a Cosh[0.4] Cos[c a/2] Cos[Sqrt[3] y a/2]+2 Sqrt[3] a Cos[c a/2]^2-I c Sqrt[3] a Sinh[0.4] Cos[c a/2] Sin[Sqrt[3] y a/2])/((Cosh[0.4]+2 Cos[c a/2] Cos[Sqrt[3] y a/2])^2-Sinh[0.4]^2-4 I Sinh[0.4] Cos[c a/2] Sin[Sqrt[3] y a/2]+4 Cos[c a/2]^2 Sin[Sqrt[3] y a/2]^2) Integrate[g[y],{y,-((2 [Pi])/(a Sqrt[3])),(2 [Pi])/(a Sqrt[3])},Assumptions->{a>0,1.45779<c<2.45804}] $\endgroup$ – D.Silva Feb 28 '18 at 20:13
  • 2
    $\begingroup$ How is it possible that you expect a numerical value if c is undetermined? $\endgroup$ – José Antonio Díaz Navas Feb 28 '18 at 20:44
  • 1
    $\begingroup$ @JoséAntonioDíazNavas also a is undetermined. Yet the answer is supposed to be 1/2. This is strange problem. Mathematica can integrate this as indefinite integration. May be the OP can try that first and see if the integrand is proper, try to take the limits and see what happens. $\endgroup$ – Nasser Feb 28 '18 at 21:26

Rationalize all the 0.4, thinking that might expose simplifications and other integration methods

g[y_] := (Sqrt[3] a Cosh[4/10] Cos[c a/2] Cos[Sqrt[3] y a/2]+2 Sqrt[3] a*
  Cos[c a/2]^2-I c Sqrt[3] a Sinh[4/10] Cos[c a/2] Sin[Sqrt[3] y a/2])/
  ((Cosh[4/10]+2 Cos[c a/2] Cos[Sqrt[3] y a/2])^2-Sinh[4/10]^2-4 I Sinh[4/10] *
  Cos[c a/2] Sin[Sqrt[3] y a/2]+4 Cos[c a/2]^2 Sin[Sqrt[3] y a/2]^2);

FullSimplify to make it smaller

FullSimplify[g[y], a > 0 && 1.45779 < c < 2.45804]

By inspection pull multiplier not dependent on y outside the integral, thinking that might simplify and speed the integration, and assume that doesn't have a zero denominator.

(Sqrt[3] a Cos[(a c)/2])/(3 + 2 Cos[a c] + 4 Cos[(a c)/2] )*
  Integrate[(2 Cos[(a c)/2]+Cos[1/2 Sqrt[3] a y] Cosh[2/5]-I c Sin[1/2 Sqrt[3] a y]*
    Sinh[2/5])/(Cos[1/2 Sqrt[3] a y] Cosh[2/5]-I Sin[1/2 Sqrt[3] a y] Sinh[2/5]),
    {y, -((2 \[Pi])/(a Sqrt[3])), (2 \[Pi])/(a Sqrt[3])},
    Assumptions -> {a > 0, 1.45779 < c < 2.45804}]

and in a few seconds the result is

(Sqrt[3] (5.25758+1.99761 c-1.77636*10^-15 Cos[(0.5+0. I) a c]-
  6.66134*10^-16 Cos[(a c)/2]) Cos[(a c)/2])/(3+4 Cos[(a c)/2]+2 Cos[a c])

It is interesting, at least to me, that while there is not a decimal point anywhere in the integrand, other than the assumptions, that the result is given in terms of approximate decimal numbers.

I'm also a little concerned that your initial f(x) started with a 1/(2 pi) but that doesn't seem to appear in your g[x] code. Are f(x) and g(x) really equivalent and correct?

|improve this answer|||||
  • $\begingroup$ Yes, f(x) and g(x) are equivalent. I forgot to type $\frac{1}{2\pi}$ in code. $\endgroup$ – D.Silva Feb 28 '18 at 22:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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