Zulip Chat Archive
Stream: Is there code for X?
Topic: absolute value and complex conjugate
Jeremy Avigad (Aug 02 2022 at 01:24):
I am confused about the right way to use absolute value and complex conjugate on the complex numbers. I need (some incarnation of) the inference below, but the proof I found seems messy and roundabout. Can someone tell me if there is a better way?
import data.complex.basic
open complex
open_locale complex_conjugate
example (z w : complex) (h : abs z = abs w) : z * star z = w * star w :=
begin
transitivity ((complex.abs z ^ 2 : ℝ) : ℂ),
{ rw [complex.sq_abs, ←complex.mul_conj], refl },
transitivity ((complex.abs w ^ 2 : ℝ) : ℂ),
{ rw h },
rw [complex.sq_abs, ←complex.mul_conj], refl
end
Eric Rodriguez (Aug 02 2022 at 01:33):
one solution that people may frown upon a little would be this:
example (z w : complex) (h : abs z = abs w) : z * star z = w * star w :=
by simpa [complex.mul_conj] using (real.sqrt_inj _ _).mp h; apply norm_sq_nonneg
Eric Rodriguez (Aug 02 2022 at 01:33):
this is a bit brittle against API change though
Anatole Dedecker (Aug 02 2022 at 01:35):
I would do
example (z w : complex) (h : abs z = abs w) : z * star z = w * star w :=
by rw [← star_ring_end_apply, complex.mul_conj, ← star_ring_end_apply, complex.mul_conj,
norm_sq_eq_abs, norm_sq_eq_abs, h]
Eric Rodriguez (Aug 02 2022 at 01:36):
one that's less hacky: simpa [complex.sq_abs, complex.mul_conj] using congr_arg (^ 2) h,
Anatole Dedecker (Aug 02 2022 at 01:36):
Yes invoking injectivity of square root seems wrong
Heather Macbeth (Aug 02 2022 at 01:39):
By the way, I think we prefer conj
over star
(in order to sound more like what outsiders expect); open_locale complex_conjugate
precisely enables the conj
notation.
Moritz Doll (Aug 02 2022 at 01:59):
using conj
also makes it possible to golf Anatole's proof to simp_rw [mul_conj, complex.norm_sq_eq_abs, h]
Anatole Dedecker (Aug 02 2022 at 02:06):
I have this habit of trying rw
before simp
and I can't decide if it's good or not :sweat_smile:
Jeremy Avigad (Aug 02 2022 at 02:32):
Thank you!
Last updated: Dec 20 2023 at 11:08 UTC