-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[Merged by Bors] - feat(SpecialFunctions/Artanh): basic definition and partial equivalence #32696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 6 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
f67b817
Add tanh_eq
YuvalFilmus b1471dc
Skeleton of artanh
YuvalFilmus b8e9898
Show the PartialEquiv
YuvalFilmus fff1c74
Update Mathlib/Analysis/SpecialFunctions/Artanh.lean
YuvalFilmus 8bce88a
Add alternative formula for artanh
YuvalFilmus a326306
Merge branch 'master' into artanh
YuvalFilmus 39f0d38
Update Mathlib/Analysis/SpecialFunctions/Artanh.lean
YuvalFilmus 56b5a58
Update Mathlib/Analysis/SpecialFunctions/Artanh.lean
YuvalFilmus e723cb2
Update Mathlib/Analysis/SpecialFunctions/Artanh.lean
YuvalFilmus c0652db
Update Mathlib/Analysis/SpecialFunctions/Artanh.lean
YuvalFilmus b8853f0
Update Mathlib/Analysis/SpecialFunctions/Artanh.lean
YuvalFilmus 7b3d7d0
Golfed artanh_tanh
YuvalFilmus 59a96e0
Extended range of validity of artanh_eq_half_log
YuvalFilmus 27a9273
Monotonicity
YuvalFilmus c30804f
Positivity and nonnegativity
YuvalFilmus 9c4e3eb
Merge branch 'master' into artanh
YuvalFilmus 4f76d66
Strengthened strictMonoOn_sqrt and moved it to its proper place
YuvalFilmus 69fc9fd
Merge branch 'master' into artanh
YuvalFilmus adef478
Merge branch 'leanprover-community:master' into artanh
YuvalFilmus 9f4fcec
bijectivity, injectivity, surjectivity
YuvalFilmus 47fcac0
Fixed docstring of artanh
YuvalFilmus bd8cff6
Remove Real.tanh_injOn
YuvalFilmus 65e86ef
Add artanh_le_artanh_iff, artanh_lt_artanh_iff
YuvalFilmus 9bf0e9f
Moved auxiliary results to Trigonometric.lean
YuvalFilmus 82cbcc3
Fixed bug in proof
YuvalFilmus 445057e
Strengthened artanh_nonneg and added artanh_neg and artanh_nonpos
YuvalFilmus b17ecf9
Update Mathlib/Analysis/SpecialFunctions/Artanh.lean
YuvalFilmus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| /- | ||
| Copyright (c) 2025 Yuval Filmus. All rights reserved. | ||
| Released under Apache 2.0 license as described in the file LICENSE. | ||
| Authors: Yuval Filmus | ||
| -/ | ||
| module | ||
|
|
||
| public import Mathlib.Analysis.SpecialFunctions.Log.Basic | ||
|
|
||
| /-! | ||
| # Inverse of the tanh function | ||
|
|
||
| In this file we define an inverse of tanh as a function from ℝ to (-1, 1). | ||
|
|
||
| ## Main definitions | ||
|
|
||
| - `Real.artanh`: An inverse function of `Real.tanh` as a function from ℝ to (-1, 1). | ||
|
|
||
| - `Real.tanhPartialEquiv`: `Real.tanh` as a `PartialEquiv`. | ||
|
|
||
| ## Main Results | ||
|
|
||
| - `Real.tanh_artanh`, `Real.artanh_tanh`: tanh and artanh are inverse in the appropriate domains. | ||
|
|
||
| ## Tags | ||
|
|
||
| artanh, arctanh, argtanh, atanh | ||
| -/ | ||
|
|
||
| @[expose] public section | ||
|
|
||
|
|
||
| noncomputable section | ||
|
|
||
| open Function Filter Set | ||
|
|
||
| open scoped Topology | ||
|
|
||
| namespace Real | ||
|
|
||
| variable {x y : ℝ} | ||
|
|
||
| /-- `artanh` is defined using a logarithm, `arcosh x = log √((1 + x) / (1 - x))`. -/ | ||
| @[pp_nodot] | ||
| def artanh (x : ℝ) := | ||
| log √((1 + x) / (1 - x)) | ||
|
|
||
| theorem artanh_eq_half_log {x : ℝ} (hx : x ∈ Ioo (-1 : ℝ) 1) : | ||
| artanh x = 1 / 2 * log ((1 + x) / (1 - x)) := by | ||
| rw [artanh, log_sqrt <| le_of_lt <| div_pos (neg_lt_iff_pos_add'.mp hx.1) (sub_pos.mpr hx.2), | ||
| one_div_mul_eq_div] | ||
|
|
||
| theorem exp_artanh {x : ℝ} (hx : x ∈ Ioo (-1 : ℝ) 1) : exp (artanh x) = √((1 + x) / (1 - x)) := | ||
| exp_log <| sqrt_pos_of_pos <| div_pos (neg_lt_iff_pos_add'.mp hx.1) (sub_pos.mpr hx.2) | ||
|
|
||
| @[simp] | ||
| theorem artanh_zero : artanh 0 = 0 := by simp [artanh] | ||
|
|
||
| theorem sinh_artanh {x : ℝ} (hx : x ∈ Ioo (-1 : ℝ) 1) : sinh (artanh x) = x / √(1 - x ^ 2) := by | ||
| have : 1 - x ^ 2 = (1 + x) * (1 - x) := by ring | ||
| rw [this, artanh, sinh_eq, exp_neg, exp_log, sqrt_div, sqrt_mul] | ||
| · field_simp | ||
| rw [sq_sqrt, sq_sqrt] | ||
| · ring | ||
| · exact le_of_lt <| sub_pos.mpr hx.2 | ||
| · exact le_of_lt <| neg_lt_iff_pos_add'.mp hx.1 | ||
| · exact le_of_lt <| neg_lt_iff_pos_add'.mp hx.1 | ||
| · exact le_of_lt <| neg_lt_iff_pos_add'.mp hx.1 | ||
| · exact sqrt_pos_of_pos <| div_pos (neg_lt_iff_pos_add'.mp hx.1) (sub_pos.mpr hx.2) | ||
|
|
||
| theorem cosh_artanh {x : ℝ} (hx : x ∈ Ioo (-1 : ℝ) 1) : cosh (artanh x) = 1 / √(1 - x ^ 2) := by | ||
| have : 1 - x ^ 2 = (1 + x) * (1 - x) := by ring | ||
| rw [this, artanh, cosh_eq, exp_neg, exp_log, sqrt_div, sqrt_mul] | ||
| · field_simp | ||
| rw [sq_sqrt, sq_sqrt] | ||
| · ring | ||
| · exact le_of_lt <| sub_pos.mpr hx.2 | ||
| · exact le_of_lt <| neg_lt_iff_pos_add'.mp hx.1 | ||
| · exact le_of_lt <| neg_lt_iff_pos_add'.mp hx.1 | ||
| · exact le_of_lt <| neg_lt_iff_pos_add'.mp hx.1 | ||
| · exact sqrt_pos_of_pos <| div_pos (neg_lt_iff_pos_add'.mp hx.1) (sub_pos.mpr hx.2) | ||
YuvalFilmus marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| /-- `artanh` is the right inverse of `tanh` over (-1, 1). -/ | ||
| theorem tanh_artanh {x : ℝ} (hx : x ∈ Ioo (-1 : ℝ) 1) : tanh (artanh x) = x := by | ||
| rw [tanh_eq_sinh_div_cosh, sinh_artanh hx, cosh_artanh hx, div_div_div_cancel_right₀, div_one] | ||
| apply sqrt_ne_zero'.mpr | ||
| rw [show 1 - x ^ 2 = (1 + x) * (1 - x) by ring] | ||
| exact mul_pos (neg_lt_iff_pos_add'.mp hx.1) (sub_pos.mpr hx.2) | ||
YuvalFilmus marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| theorem tanh_lt_one (x : ℝ) : tanh x < 1 := by | ||
| rw [tanh_eq] | ||
| field_simp | ||
| suffices 0 < rexp (-x) by linarith | ||
| positivity | ||
YuvalFilmus marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| theorem neg_one_lt_tanh (x : ℝ) : -1 < tanh x := by | ||
| rw [tanh_eq] | ||
| field_simp | ||
| suffices 0 < rexp x by linarith | ||
| positivity | ||
YuvalFilmus marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| /-- `artanh` is the left inverse of `tanh`. -/ | ||
| theorem artanh_tanh (x : ℝ) : artanh (tanh x) = x := by | ||
| rw [artanh, ← exp_eq_exp, exp_log, ← sq_eq_sq₀, sq_sqrt, tanh_eq, exp_neg] | ||
| · field | ||
| · exact le_of_lt <| div_pos | ||
| (neg_lt_iff_pos_add'.mp (neg_one_lt_tanh x)) (sub_pos.mpr (tanh_lt_one x)) | ||
| · positivity | ||
| · positivity | ||
| · exact sqrt_pos_of_pos <| div_pos | ||
| (neg_lt_iff_pos_add'.mp (neg_one_lt_tanh x)) (sub_pos.mpr (tanh_lt_one x)) | ||
|
|
||
| /-- `Real.tanh` as a `PartialEquiv`. -/ | ||
| def tanhPartialEquiv : PartialEquiv ℝ ℝ where | ||
| toFun := tanh | ||
| invFun := artanh | ||
| source := univ | ||
| target := Ioo (-1 : ℝ) 1 | ||
YuvalFilmus marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| map_source' r _ := mem_Ioo.mpr ⟨neg_one_lt_tanh r, tanh_lt_one r⟩ | ||
| map_target' _ _ := trivial | ||
| left_inv' r _ := artanh_tanh r | ||
| right_inv' _ hr := tanh_artanh hr | ||
|
|
||
| end Real | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mathlib/Analysis/SpecialFunctions/Log/Deriv.leanuses the expression1 / 2 * log ((1 + x) / (1 - x))a few times (see #31487) as a stand-in forartanh.I agree with the choice to go with sqrt so that the junk values outside of the domain will all be zero, but perhaps you should add a lemma for
1 / 2 * log ((1 + x) / (1 - x)) = artanh xfor all0 ≤ x(usingReal.log_sqrtandone_div_mul_eq_div). That file should probably import this file and use the newartanhin those places.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a theorem
artanh_eq_half_log.Perhaps the name could be improved.
I don't immediately see how to prove it for all
0 ≤ x.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is quite annoying that positivity doesn't work here (as well as elsewhere in this file).
Why is that the case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes sorry I meant for all
xwhere the thing inside the square root is non-negative.You can extend the
IootoIcc:I think that
positivitywon't do ring operations, but I'm not sure. It does know how to handle the division if you help it:it just doesn't know how to convert
-1 ≤ xto0 ≤ 1 + xandx ≤ 1to0 ≤ 1 - x.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably it doesn't matter, but I'll mention that if one instead chooses
artanh x := 1 / 2 * log ((1 + x) / (1 - x)), then the junk values forReal.logguarantee thatartanh x⁻¹ = (artanh x)⁻¹for allx.