I have a simple integral of an absolute value. However, the output is showing an imaginary unit. In a previous question I have been told the problem is the Series. Can anybody help?

Adding ComplexExpand doesn't seem to help. I really believe I shouldn't see any I, can anybody confirm that? I am having a lot of problems to understand why I appears.

 dWNorm[x_] = 
Piecewise[{{(-c *(B1  Cos[B1 x] - B1  Cosh[B1  x]) - B1  Sin[B1  x] -
   B1  Sinh[B1  x]), 0 <= x <= 1}}]
IntegrandON[x_, z_] = 
Abs[Series[(1 - ((1 - I)/2)*Sqrt[beta/2]*
     Cosh[(1 - I)*z*
        Sqrt[beta/2]]/(Sinh[(1 - I)/2*Sqrt[ beta/2]]))*(dWNorm[
    x]), {beta, 0, 2}]]^2;
IntegralON = 
beta/(16*Integrate[IntegrandON[x, z], {x, -1, 1}, {z, -1/2, 1/2}])
| improve this question | | | | |
  • $\begingroup$ What is dWNorm? $\endgroup$ – user64494 Apr 12 '17 at 14:42
  • $\begingroup$ @user64494 it is my own defined function. I can edit it but I don't see why that is important for what I asked. B1 is a real, c too. $\endgroup$ – Andrea G Apr 12 '17 at 14:47
  • 2
    $\begingroup$ That imaginary unit is showing up inside the Abs, just like it does here: In[224]:= Abs[1 + I*x] Out[224]= Abs[1 + I x]. I see no issue with that. $\endgroup$ – Daniel Lichtblau Apr 12 '17 at 21:35
  • $\begingroup$ @DanielLichtblau But as I stated, using ComplexExpand didnt help. If you do Abs[1+I*x]//ComplexExpand you get in fact Sqrt[1+x^2] $\endgroup$ – Andrea G Apr 13 '17 at 9:11
  • $\begingroup$ Might try it with ComplexExpand[Abs[Normal[Series[...]]]. $\endgroup$ – Daniel Lichtblau Apr 13 '17 at 16:54
dWNorm[x_] = 
  Piecewise[{{(-c*(B1 Cos[B1 x] - B1 Cosh[B1 x]) - B1 Sin[B1 x] - 
       B1 Sinh[B1 x]), 0 <= x <= 1}}];

Use Normal after the Series. Use PiecewiseExpand to simplify the combination of Piecewise functions. Since you mentioned ComplexExpand without stating any limitations, I assume that all variables are real. Use TargetFunctions->{Re, Im} with ComplexExpand

IntegrandON[x_, z_] = Abs[
       Series[(1 - ((1 - I)/2)*Sqrt[beta/2]*
             Cosh[(1 - I)*z*
                Sqrt[beta/2]]/(Sinh[(1 - I)/2*Sqrt[beta/2]]))*(dWNorm[
            x]), {beta, 0, 2}] // Normal]^2 //
     PiecewiseExpand //
    ComplexExpand[#, TargetFunctions -> {Re, Im}] & //

IntegralON = 
 beta/(16*Integrate[IntegrandON[x, z], {x, -1, 1}, {z, -1/2, 1/2}]) // 

(*  302400/(B1 beta (1680 + beta^2) (2 c (-2 + 2 B1 c - Cos[2 B1]) - 
     2 c Cosh[2 B1] + 
     4 Cosh[B1] (2 c Cos[B1] + Sin[B1] - c^2 Sin[B1]) + (-1 + c^2) Sin[
       2 B1] - 4 (1 + c^2) Cos[B1] Sinh[B1] + Sinh[2 B1] + c^2 Sinh[2 B1]))  *)
| improve this answer | | | | |
  • $\begingroup$ I thank you for your answer. I will now try to understand: in the meantime could you mention WHY I have to do all this? Why isn't it automatically giving the result without any I? My big doubt is: if I hadn't done all the things you showed, would the result have been wrong? Or would it have been given in another output form, but still correct? What I am doubtful of is: if I dont give all these extra information after Abs, are the two results Completely different? $\endgroup$ – Andrea G Apr 12 '17 at 15:48
  • 1
    $\begingroup$ Read the doc for Series and Normal for why Normal is needed. Read docs for PiecewiseExpand to see why it is used. Abs is a perfectly reasonable and compact way of expressing a real value. ComplexExpand doesn't know that you want another representation and has no reason to change the expression unless you specify that you want different TargetFunctions. $\endgroup$ – Bob Hanlon Apr 12 '17 at 16:03
  • $\begingroup$ Ok, I will do all you said: can you discuss about my doubt on the correctness of both the outputs?That is: is my code wrong or just different from yours in terms of output form? This is really important for me to understand better Mathematica $\endgroup$ – Andrea G Apr 12 '17 at 16:08
  • 1
    $\begingroup$ @AndreaG - there are multiple equivalent representations for any expression; the specific one used is dependent on the context. Mma in general operates in the complex plane and "complex looking" representations of real expressions arise from the algorithms that are built to handle complex expressions. As stated previously, ComplexExpand is correct in considering Abs[expr] as real and if you want a different representation you need to specify other TargetFunctions. $\endgroup$ – Bob Hanlon Apr 12 '17 at 16:28
  • 1
    $\begingroup$ @AndreaG - For an example of real-valued expressions that must contain complex-valued expressions, see Casus irreducibilis $\endgroup$ – Bob Hanlon Apr 13 '17 at 4:25

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