Skip to content

devmotion/FresnelIntegrals.jl

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FresnelIntegrals.jl

Stable Dev Build Status Coverage

A quick Julia library for calculating Fresnel Integrals using the error function from SpecialFunctions.jl.

using FresnelIntegrals
using Plots

z = -30:0.001:30
plot(x->real(fresnelc(x)), x->real(fresnels(x)),z,legend=false)
title!("Euler Spiral")
xlabel!("C(z)")
ylabel!("S(z)")

Spiral

As expected, this is much faster than the numeric integral solution

using QuadGK
using FresnelIntegrals

julia> @benchmark fresnelc(1.8)
BenchmarkTools.Trial: 10000 samples with 772 evaluations.
 Range (min  max):  161.448 ns   1.744 μs  ┊ GC (min  max): 0.00%  0.00%
 Time  (median):     163.927 ns              ┊ GC (median):    0.00%
 Time  (mean ± σ):   164.460 ns ± 16.519 ns  ┊ GC (mean ± σ):  0.00% ± 0.00%

  ▃▄▂                ▁▇█▄          ▁  ▃▄▂▁        ▁▁▁          ▂
  ███▇▁▃▁▁▁▁▁▁▁▁▁▁▅▇▅█████▁▄▄▄▆▆▅▆▆█▇▆█████▇▆▅▅▇██████▇▇▆▇▇▆▅▆ █
  161 ns        Histogram: log(frequency) by time       168 ns <

 Memory estimate: 0 bytes, allocs estimate: 0.

julia> @benchmark quadgk(t->cos*t^2/2),0,1.8)
BenchmarkTools.Trial: 10000 samples with 187 evaluations.
 Range (min  max):  548.321 ns   48.949 μs  ┊ GC (min  max): 0.00%  98.43%
 Time  (median):     554.893 ns               ┊ GC (median):    0.00%
 Time  (mean ± σ):   599.010 ns ± 558.147 ns  ┊ GC (mean ± σ):  2.25% ±  3.29%

  ▅█▆▂▄▃▃▁▁▁▁▁                    ▂▁                  ▁▁▁▁▂▁    ▁
  ███████████████▇▅▆▅▄▃▅▄▅▅▅▄▄▃▄████████▇▇▆▆▇▆▆▆▇▇▇▇▇█████████▇ █
  548 ns        Histogram: log(frequency) by time        754 ns <

 Memory estimate: 368 bytes, allocs estimate: 2.

About

Provides the sine and cosine fresnel integrals for Julia

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Julia 100.0%