View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
FresnelS and FresnelC

Join the 15-year community celebration.

Play games and win prizes!

» Learn more

5.0 | 2 ratings Rate this file 11 Downloads (last 30 days) File Size: 2.34 MB File ID: #28765 Version: 1.1
image thumbnail

FresnelS and FresnelC


John D'Errico (view profile)


19 Sep 2010 (Updated )

Efficient and accurate computation of the Fresnel sine and cosine integrals

| Watch this File

File Information

I noticed the many codes on the FEX to compute the Fresnel integrals for real arguments, and it left me wondering how I might try solving this problem in MATLAB for both high accuracy and high efficiency.

The approach I took yields a maximum error of roughly 1e-14 as far as I could get reasonable values to compare it to. (The screenshot shows the predicted error for a sampling of points.)

I've supplied functions for both the Fresnel sine and cosine integrals, as well as a .pdf file that explains the approach I took.

Evaluate the Fresnel cosine integral C(x) at x = 1.38

>> fresnelC(1.38,0)
ans =
Verify the correctness of this value using quadgk.

>> FresnelCObj = @(t) cos(pi*t.^2/2);
>> quadgk(FresnelCObj,0,1.38,'abstol',1e-15')
ans =
Now, how fast is fresnelC? Using Steve Eddins timeit code to yield an accurate estimate of the time required, we see that it is reasonably fast for scalar input.

>> timeit(@() fresnelC(1.38))
ans =
More importantly, these functions are properly vectorized. So 1 million evaluations are easy to do, and are much faster than 1 million times the time taken for one evaluation.

>> T = rand(1000000,1);
>> tic
>> FCpred = fresnelC(T);
>> toc
Elapsed time is 0.226884 seconds.


Jim Mc Elwaine, Fresnel Sine And Cosine Integrals, Computation Of Special Functions, Fresnel Integrals, Fresnel Cosine And Sine Integral Function, Fresnel Integral, Fresnel Integrals, Cornu Spiral Fresnel Integral, Complex Erf (Error Function), Fresnel Integrals, and Fresnel Integral inspired this file.

MATLAB release MATLAB 7.10 (R2010a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (4)
20 Jul 2016 Amir Khabbazi Oskouei  
02 May 2012 John D'Errico

John D'Errico (view profile)

New version submitted - thanks to Felipe.

Comment only
02 May 2012 Felipe

Felipe (view profile)

Hi John. Thanks for citing ("acknowledging") related submissions. There are two new ones, that came after yours: 33577 and 34134. You might want to cite these, too. That way folks will find your submission in all cases. I'm trying to kill duplicates. I'm assuming yours is superior -- both in accuracy and speed, not to mention readability.

Comment only
12 Oct 2010 John Kot  
03 May 2012 1.1

Acknowledge two other files

Contact us