-
Notifications
You must be signed in to change notification settings - Fork 1k
feat: Add error function (erf) and complementary error function (erfc) #34053
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
base: master
Are you sure you want to change the base?
feat: Add error function (erf) and complementary error function (erfc) #34053
Conversation
PR summary 95093e961cImport changes for modified filesNo significant changes to the import graph Import changes for all files
|
855b677 to
0d97daa
Compare
|
I'm a bit new to Lean and I was relying on LLMs for the details of this, so please review with that in mind. |
✅ PR Title Formatted CorrectlyThe title of this PR has been updated to match our commit style conventions. |
0d97daa to
98cef5a
Compare
|
|
||
| /-- The error function `erf(x) = (2/√π) ∫₀ˣ e^(-t²) dt`. -/ | ||
| def erf (x : ℝ) : ℝ := | ||
| (2 / sqrt π) * ∫ t in (0)..x, exp (-(t ^ 2)) |
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.
I wonder if we can get a complex error function somehow? It would be an antiderivative of (2/√π) e^(-z²) taking the value 0 for z = 0.
|
|
||
| open MeasureTheory Set Filter Topology | ||
|
|
||
| noncomputable section |
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.
| noncomputable section | |
| public noncomputable section |
so the results can be used in other files
Summary
I was doing some finance math and needed the Error Function, so I thought I'd contribute it.
Main definitions
Real.erf: The error function, defined as(2/√π) ∫₀ˣ e^(-t²) dtReal.erfc: The complementary error function, defined as1 - erf xMain results
Real.erf_zero:erf 0 = 0Real.erf_neg:erfis an odd function:erf (-x) = -erf xReal.erf_tendsto_one:erf x → 1asx → ∞Real.erf_tendsto_neg_one:erf x → -1asx → -∞Real.erf_le_one:erf x ≤ 1for allxReal.neg_one_le_erf:-1 ≤ erf xfor allxReal.deriv_erf:deriv erf x = (2/√π) * exp(-x²)Real.differentiable_erf:erfis differentiableReal.continuous_erf:erfis continuousReal.strictMono_erf:erfis strictly monotoneAlso adds
erftodocs/overview.yamlunder Special Functions.lake exe runLinterpasseslake exe mk_all --checkpasses