4
$\begingroup$

Bug introduced after 11.3, in or before 12.3, persisting through 13.0.


Consider the following sample:

{Re, Im}[u'[t]] // Through // ComplexExpand

In v9.0.1 u'[t] is assumed as real:

enter image description here

But at least since v12.3.1 the behavior changes:

enter image description here

Is this a bug or incompatible change?

Is there a simple way to bring back the old behavior? (This answer of mine is broken at the moment due to the change. )

$\endgroup$
5
  • $\begingroup$ The docs indicate no update to ComplexExpand since V6.0, so you should report it. $\endgroup$
    – Michael E2
    Jun 24 at 17:31
  • $\begingroup$ I get the first (desired) result on 11.3.0 for Mac OS X. $\endgroup$
    – march
    Jun 24 at 17:33
  • $\begingroup$ Possible workaround: Activate@ComplexExpand[{Re, Im}[Inactivate[u'[t]]] // Through] $\endgroup$
    – Michael E2
    Jun 24 at 17:35
  • $\begingroup$ A workaround: Simplify[{Re, Im}[u'[t]] // Through, u'[t] \[Element] Reals]. Or, to have the assumptions persist and just use Simplify: $Assumptions = $Assumptions && u'[t] \[Element] Reals; {Re, Im}[u'[t]] // Through // Simplify $\endgroup$
    – thorimur
    Jun 24 at 20:35
  • 2
    $\begingroup$ Filing a bug report for this. $\endgroup$ Jun 24 at 20:48

2 Answers 2

4
$\begingroup$

Comments have identified this as a bug; in the meantime, a simple way to bring back the old behavior for ComplexExpand in a given session can be obtained by adding the following definition to ComplexExpand. This builds on Michael E2's (in)activation workaround; I noticed that it really is just the Derivative symbol itself that gives us grief, so we can restrict our inactivation to Derivative per se.

Unprotect[complexExpandIntercept, ComplexExpand];
complexExpandIntercept = True;
ComplexExpand[args___] := 
 Block[{complexExpandIntercept = False}, 
   Activate[
    ComplexExpand @@ Inactivate[{args}, Derivative], 
    Derivative]] /; complexExpandIntercept
Protect[complexExpandIntercept, ComplexExpand];
{Re, Im}[u'[t]] // Through // ComplexExpand

(* Out: {Derivative[1][u][t], 0} *)

Note: for a brief moment this answer was incorrect due to flipped booleans; now it should be fixed. :)

$\endgroup$
4
$\begingroup$

Here another workaround that may be safe (as it would likely affect only expressions containing u'):

ComplexExpand[Null]; (* autoload ComplexExpandDump *)
Block[{System`ComplexExpandDump`ConjugateFunctions = 
   Append[System`ComplexExpandDump`ConjugateFunctions, u']},
 ComplexExpand[{Re, Im}[u'[t]] // Through]]
(*  {u'[t], 0}  *)
$\endgroup$
2
  • $\begingroup$ I think you mean ComplexExpand[u'[t] // Re] :) ? Then, it seems that we need to use ComplexExpand at least once before using the solution, otherwise System`ComplexExpandDump`ConjugateFunctions won't be loaded. $\endgroup$
    – xzczd
    Jun 25 at 2:01
  • $\begingroup$ @xzczd Thanks! (It turns out internally it complex-expands the real and imaginary parts of u'[t] anyway, so that at some point I dropped the Re and Im.) $\endgroup$
    – Michael E2
    Jun 25 at 3:09

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.