@@ -12,11 +12,14 @@ module complex-numbers.magnitude-complex-numbers where
1212open import complex-numbers.complex-numbers
1313open import complex-numbers.conjugation-complex-numbers
1414open import complex-numbers.multiplication-complex-numbers
15+ open import complex-numbers.similarity-complex-numbers
1516
1617open import foundation.action-on-identifications-functions
18+ open import foundation.dependent-pair-types
1719open import foundation.identity-types
1820open import foundation.universe-levels
1921
22+ open import real-numbers.absolute-value-real-numbers
2023open import real-numbers.addition-nonnegative-real-numbers
2124open import real-numbers.addition-real-numbers
2225open import real-numbers.dedekind-real-numbers
@@ -25,6 +28,7 @@ open import real-numbers.multiplication-nonnegative-real-numbers
2528open import real-numbers.multiplication-real-numbers
2629open import real-numbers.negation-real-numbers
2730open import real-numbers.nonnegative-real-numbers
31+ open import real-numbers.positive-real-numbers
2832open import real-numbers.raising-universe-levels-real-numbers
2933open import real-numbers.rational-real-numbers
3034open import real-numbers.similarity-real-numbers
@@ -225,3 +229,67 @@ abstract
225229 = magnitude-ℂ z *ℝ magnitude-ℂ w
226230 by ap real-ℝ⁰⁺ (distributive-sqrt-mul-ℝ⁰⁺ _ _)
227231```
232+
233+ ### The magnitude of a real number as a complex number is its absolute value
234+
235+ ``` agda
236+ abstract
237+ magnitude-complex-ℝ :
238+ {l : Level} (x : ℝ l) → magnitude-ℂ (complex-ℝ x) = abs-ℝ x
239+ magnitude-complex-ℝ {l} x =
240+ equational-reasoning
241+ real-sqrt-ℝ⁰⁺
242+ ( nonnegative-square-ℝ x +ℝ⁰⁺ nonnegative-square-ℝ (raise-ℝ l zero-ℝ))
243+ =
244+ real-sqrt-ℝ⁰⁺
245+ ( nonnegative-square-ℝ x +ℝ⁰⁺ nonnegative-square-ℝ zero-ℝ)
246+ by
247+ ap
248+ ( real-sqrt-ℝ⁰⁺)
249+ ( eq-ℝ⁰⁺ _ _
250+ ( eq-sim-ℝ
251+ ( preserves-sim-left-add-ℝ _ _ _
252+ ( preserves-sim-square-ℝ
253+ ( symmetric-sim-ℝ (sim-raise-ℝ l zero-ℝ))))))
254+ = real-sqrt-ℝ⁰⁺ (nonnegative-square-ℝ x +ℝ⁰⁺ zero-ℝ⁰⁺)
255+ by ap real-sqrt-ℝ⁰⁺ (eq-ℝ⁰⁺ _ _ (ap-add-ℝ refl square-zero-ℝ))
256+ = real-sqrt-ℝ⁰⁺ (nonnegative-square-ℝ x)
257+ by ap real-sqrt-ℝ⁰⁺ (eq-ℝ⁰⁺ _ _ (right-unit-law-add-ℝ _))
258+ = abs-ℝ x
259+ by inv (eq-abs-sqrt-square-ℝ x)
260+ ```
261+
262+ ### Similar complex numbers have similar magnitudes
263+
264+ ``` agda
265+ abstract
266+ preserves-sim-squared-magnitude-ℂ :
267+ {l1 l2 : Level} {z : ℂ l1} {w : ℂ l2} →
268+ sim-ℂ z w → sim-ℝ (squared-magnitude-ℂ z) (squared-magnitude-ℂ w)
269+ preserves-sim-squared-magnitude-ℂ (a~c , b~d) =
270+ preserves-sim-add-ℝ
271+ ( preserves-sim-square-ℝ a~c)
272+ ( preserves-sim-square-ℝ b~d)
273+
274+ preserves-sim-magnitude-ℂ :
275+ {l1 l2 : Level} {z : ℂ l1} {w : ℂ l2} →
276+ sim-ℂ z w → sim-ℝ (magnitude-ℂ z) (magnitude-ℂ w)
277+ preserves-sim-magnitude-ℂ z~w =
278+ preserves-sim-sqrt-ℝ⁰⁺ _ _ (preserves-sim-squared-magnitude-ℂ z~w)
279+ ```
280+
281+ ### The magnitude of ` one-ℂ ` is ` one-ℝ `
282+
283+ ``` agda
284+ abstract
285+ magnitude-one-ℂ : magnitude-ℂ one-ℂ = one-ℝ
286+ magnitude-one-ℂ =
287+ equational-reasoning
288+ magnitude-ℂ one-ℂ
289+ = magnitude-ℂ (complex-ℝ one-ℝ)
290+ by ap magnitude-ℂ (inv eq-complex-one-ℝ)
291+ = abs-ℝ one-ℝ
292+ by magnitude-complex-ℝ one-ℝ
293+ = one-ℝ
294+ by abs-real-ℝ⁺ one-ℝ⁺
295+ ```
0 commit comments