forked from JuliaMath/SpecialFunctions.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added fresnel integrals from this repo : https://github.com/kiranshila/FresnelIntegrals.jl. As suggested in JuliaMath#398
- Loading branch information
1 parent
36c547b
commit c3474da
Showing
4 changed files
with
41 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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,25 @@ | ||
|
||
|
||
# Code ported from https://github.com/kiranshila/FresnelIntegrals.jl | ||
|
||
|
||
""" | ||
fresnelc(z) | ||
Calculates the Fresnel cosine integral for the number z for | ||
``C(z) = \\int_{0}^{z} \\cos{\\left(\\frac{\\pi t^2}{2}\\right)}dt`` | ||
""" | ||
fresnelc(z::Number) = 0.25*(1-1im)*(1im*erf(0.5*(1-1im)*z*√(π)) + erf(0.5*(1+1im)*z*√(π))) | ||
|
||
""" | ||
fresnels(z) | ||
Calculates the Fresnel sine integral for the number z for | ||
``S(z) = \\int_{0}^{z} \\sin{\\left(\\frac{\\pi t^2}{2}\\right)}dt`` | ||
""" | ||
fresnels(z::Number) = 0.25*(1+1im)*(-1im*erf(0.5*(1-1im)*z*√(π)) + erf(0.5*(1+1im)*z*√(π))) | ||
|
||
""" | ||
fresnel(z) | ||
Calculates the cosine and sine fresnel integrals | ||
""" | ||
fresnel(z::Number) = (fresnelc(z),fresnels(z)) | ||
|
This file contains 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,9 @@ | ||
@testset "fresnel" begin | ||
# Precise values come from WolframAlpha calculator | ||
# One could add more decimals and more tests if needed | ||
|
||
@test fresnels(1.) ≈ 0.4382591473903 | ||
@test fresnelc(1.) ≈ 0.7798934003768 | ||
@test fresnels(sqrt(2)) ≈ 0.7139722140219 | ||
@test fresnelc(sqrt(2)) ≈ 0.5288915951112 | ||
end |
This file contains 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