1
$\begingroup$

Let's start with this function

expr = Abs[((x + a) (y + b)) c]^2

with this assumptions

$Assumptions={Element[x,Reals], Element[y,Reals] ,a>0,b>0,Element[c,Complexes]};

Now something strange happens when I use the TargetFunctions options: If I calculate

FullSimplify[(ComplexExpand[
    D[expr, y, x] /.{x -> 0, y -> 0}
    , c, TargetFunctions -> {Abs, Arg}]) - (ComplexExpand[
    D[expr, y, x] /.{x -> 0, y -> 0}
    , c])]

the output is 0, as I expect.

But if I calculate the same with an extra FullSimplyfy I have a different output:

FullSimplify[(ComplexExpand[
    D[expr, y, x] /.{x -> 0, y -> 0}
    , c, TargetFunctions -> {Abs, Arg}]) - (FullSimplify[ComplexExpand[
     D[expr, y, x] /.{x -> 0, y -> 0}
     , c]])]

here the output is

-2 a b (-Sqrt[c^2] Abs[c] + Sqrt[c^3 Conjugate[c]])
  • Why is the last result not zero?
  • Why is the output different in the two cases?

Thank you

$\endgroup$
8
  • $\begingroup$ Both give 0 for me. $\endgroup$
    – Feyre
    Commented Nov 2, 2016 at 9:36
  • $\begingroup$ The second is mathematically also zero because Sqrt[ c Conjugate[c] ]== Abs[c] $\endgroup$
    – corey979
    Commented Nov 2, 2016 at 10:06
  • $\begingroup$ This is strange... I'm running Mathematica 11.0.1.0 on Linux (64bit) I just give, as first input (that means the kernel is clean) the input $Assumptions = {Element[x,Reals], Element[y,Reals], a > 0, b > 0, Element[c,Complexes]}; Abs[((x + a) (y + b)) c]^2; FullSimplify[(ComplexExpand[ D[%, y, x] /. {x -> 0, y -> 0} , c, TargetFunctions -> {Abs, Arg}]) - (FullSimplify[ComplexExpand[ D[%, y, x] /. {x -> 0, y -> 0} , c]])] and it returns -2 a b (-Sqrt[c^2] Abs[c] + Sqrt[c^3 Conjugate[c]]) not zero... $\endgroup$
    – Giancarlo
    Commented Nov 2, 2016 at 11:05
  • $\begingroup$ I cannot believe this!! If I write the expression with 2 new lines after each semicolon I get the wrong result; if I delete these new lines (I make them just pressing the 'enter' button (the one above the shift button) without any text) I get zero!!! I don't know how to record this behaviour but I should, it's very strange!!! $\endgroup$
    – Giancarlo
    Commented Nov 2, 2016 at 11:27
  • $\begingroup$ @Giancarlo - Question 128818 may have something to do with the semicolon issue. $\endgroup$
    – Soldalma
    Commented Nov 2, 2016 at 11:34

1 Answer 1

1
$\begingroup$

This isn't really an answer to the two questions, but may yield some insights.

In SE post #24514 Stephen Kuhn reproduced function PowerContract, originally from the book Quantum Methods with Mathematica by James Feagin. Using that function one can get to the desired (zero) output.

$Assumptions = {Element[x, Reals], Element[y, Reals], a > 0, b > 0, 
   Element[c, Complexes]};
PowerContract[expr_] := 
 expr //. {m_^q_ n_^q_ :> (m n)^q /; ! IntegerQ[m] && ! IntegerQ[n], 
   m_^q_ n_^p_ :> (m/n)^q /; 
     q >= 0 && p == -q && ! IntegerQ[m] && ! IntegerQ[n]}
expr1 = -2 a b (-Sqrt[c^2] Abs[c] + Sqrt[c^3 Conjugate[c]]);
expr2 = expr1/(-2 a b) (* Get rid of constants *)
(* -Sqrt[c^2] Abs[c]+Sqrt[c^3 Conjugate[c]] *)
expr3 = PowerExpand[expr2]
(* -c Abs[c]+c^(3/2) Sqrt[Conjugate[c]] *)
expr4 = Factor[expr3]/c (* Dividing expr3 by c doesn't help *)
(* -Abs[c]+Sqrt[c] Sqrt[Conjugate[c]] *)
expr5 = PowerContract /@ expr4
(* -Abs[c]+Sqrt[c Conjugate[c]] *)
expr5 // FullSimplify
(* 0 *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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