2

I have looked at similar posts, such as this one, but none of the solutions have worked for me. I have an imaginary function, and I have tried to obtain its real part using Re, ComplexExpand with Re, Simplify with ComplexExpand with Re, among other methods. The function plots as expected almost every time, but when I differentiate it using methods like D or the deriv method mentioned in the post, and I obtain the value, it never comes out as accurate. Can anyone please help?

Edit: The function resembles a wave function and is of form $\sum a\sin(x)e^{b(t-tf)}$, where $a, b \in \alpha+\beta \iota$ and $\alpha \ne 0$. So ideally if we expand the function and collect only the real elements (without the Re applied to it), it should be differentiable.

AsukaMinato
  • 9,758
  • 1
  • 14
  • 40
Bravyi
  • 21
  • 2
  • 3
    Welcome to Mathematica StackExchange! We can probably help, but we cannot do it without having your function. So please copy and paste the function from Mathematica into your question :) – Domen Dec 18 '23 at 18:17
  • 4
    This post might be useful https://math.stackexchange.com/q/3197068/435814 – yarchik Dec 18 '23 at 18:19
  • Thank you for the warm welcome @Domen! I have edited the question to include the general form of the function. Thanks in advance! – Bravyi Dec 19 '23 at 05:46
  • 1
    Please do provide the actual function you wish to differentiate or a simplified version of it that exhibits your concerns. – bbgodfrey Dec 19 '23 at 14:27

2 Answers2

5

If f is a complex function, Re[f] does not have a derivative! One condition that a derivative exists is that the derivative is independent of the direction. E.g. the derivative in the direction of the real axis must equal the derivative in the direction of the imaginary axis.

Now consider the derivative of the function:

f[z] = Re[z]

The derivative in the direction of the real axis:

Limit[(Re[x + dx + I y] - Re[x + I y]) / dx], dx -> 0] == dx / dx == 1

And in the direction of the imaginary axis:

Limit[(Re[x + I (y + dy)] - Re[x + I y]) / dx], dx -> 0] == 0 / dy == 0

They are different, therefore Re does not have a derivative.

flinty
  • 25,147
  • 2
  • 20
  • 86
Daniel Huber
  • 51,463
  • 1
  • 23
  • 57
5
$Version

(* "13.3.1 for Mac OS X ARM (64-bit) (July 24, 2023)" *)

Clear["Global`*"]

You can take the derivative if Re[f[x]] evaluates to an explicit real function

For example,

f[x_] := LaguerreL[3, I*x]

ReIm[f[x]]

(* {1/6 (6 - Im[-18 x + x^3] - 9 Re[x^2]), 1/6 (-9 Im[x^2] + Re[-18 x + x^3])} *)

Assuming[x ∈ Reals, ReIm[f[x]] // Simplify]

(* {1 - (3 x^2)/2, 1/6 x (-18 + x^2)} *)

Assuming[x ∈ Reals, D[ReIm[f[x]] // Simplify, x]]

(* {-3 x, x^2/3 + 1/6 (-18 + x^2)} *)

Assuming[{x, y} ∈ Reals, ReIm[f[x + I*y]] // Simplify]

(* {1 + 1/6 (3 + y) (-3 x^2 + y (6 + y)), 1/6 (x^3 - 3 x (6 + 6 y + y^2))} *)

Assuming[{x, y} ∈ Reals, D[ReIm[f[x + I*y]] // Simplify, x] // Simplify]

(* {-x (3 + y), 1/2 (-6 + x^2 - 6 y - y^2)} *)

Bob Hanlon
  • 157,611
  • 7
  • 77
  • 198
  • Re[f[x]] evaluates to an explicit real function. However, sometimes Simplify just evaluates the function to zero, which is not true, so I can't use that in general. – Bravyi Dec 19 '23 at 09:41