My Math Forum  

Go Back   My Math Forum > College Math Forum > Applied Math

Applied Math Applied Math Forum


Reply
 
LinkBack Thread Tools Display Modes
February 28th, 2014, 09:54 AM   #1
Senior Member
 
fysmat's Avatar
 
Joined: Dec 2013
From: some subspace

Posts: 212
Thanks: 72

Math Focus: real analysis, vector analysis, numerical analysis, discrete mathematics
Computing the error function

My first question here...

I was coding an application that involves the computation of error function



I'd need an accuracy (absolute error) of at least, preferably .

At this point, I've tried Maclaurin serie, asymptotic serie and trapetzoid rule of integration but there were problems in accuracy and convergence in this interval. Currently the best absolute error I can get, is .

Any ideas what kind of method to use next?
fysmat is offline  
 
February 28th, 2014, 10:04 AM   #2
Global Moderator
 
CRGreathouse's Avatar
 
Joined: Nov 2006
From: UTC -5

Posts: 16,046
Thanks: 938

Math Focus: Number theory, computational mathematics, combinatorics, FOM, symbolic logic, TCS, algorithms
Re: Computing the error function

Well, I suggest PARI/GP (see my .sig below):
Code:
> 1-erfc(.5)
%1 = 0.5204998778130465376827466538919645287364515757579637000588057256471935
which takes about 70 microseconds to find the answer to 77 significant digits on my (older) machine.
CRGreathouse is offline  
February 28th, 2014, 12:02 PM   #3
Senior Member
 
fysmat's Avatar
 
Joined: Dec 2013
From: some subspace

Posts: 212
Thanks: 72

Math Focus: real analysis, vector analysis, numerical analysis, discrete mathematics
Re: Computing the error function

Thank you, but well, I'd believe, that's not allowed since we have to code our own program and prosedures to do things. But the algorithm they are using sounds pretty interesting.
fysmat is offline  
February 28th, 2014, 01:50 PM   #4
Global Moderator
 
CRGreathouse's Avatar
 
Joined: Nov 2006
From: UTC -5

Posts: 16,046
Thanks: 938

Math Focus: Number theory, computational mathematics, combinatorics, FOM, symbolic logic, TCS, algorithms
Re: Computing the error function

Sorry, that wasn't clear to me. If you'd like, though, you can peek at their source code here:
http://pari.math.u-bordeaux.fr/cgi-bin/ ... s3.c#l1122

Note that the function finds erfc(x), which is related to erf(x) by erf(x) = 1 - erfc(x).
CRGreathouse is offline  
March 1st, 2014, 03:55 AM   #5
Senior Member
 
fysmat's Avatar
 
Joined: Dec 2013
From: some subspace

Posts: 212
Thanks: 72

Math Focus: real analysis, vector analysis, numerical analysis, discrete mathematics
Re: Computing the error function

No problem! Thank you for your help. I looked at the PARI/GP code a little bit, but then I just decided to make some kind of composition of different methods (Maclaurin serie, trapetzoid rule and asymptotic serie). The solution is not quite elegant, but anyway I get the good enough accuracy. The speed then... I have to think about it.
fysmat is offline  
March 1st, 2014, 06:52 AM   #6
Global Moderator
 
CRGreathouse's Avatar
 
Joined: Nov 2006
From: UTC -5

Posts: 16,046
Thanks: 938

Math Focus: Number theory, computational mathematics, combinatorics, FOM, symbolic logic, TCS, algorithms
Re: Computing the error function

Quote:
Originally Posted by fysmat
No problem! Thank you for your help. I looked at the PARI/GP code a little bit, but then I just decided to make some kind of composition of different methods (Maclaurin serie, trapetzoid rule and asymptotic serie). The solution is not quite elegant, but anyway I get the good enough accuracy. The speed then... I have to think about it.
There's nothing wrong with that sort of approach -- sometimes it's referred to as a "polyalgorithm", where you have several algorithms and choose which one is best based on the arguments or the precision desired.
CRGreathouse is offline  
March 1st, 2014, 07:18 AM   #7
Senior Member
 
fysmat's Avatar
 
Joined: Dec 2013
From: some subspace

Posts: 212
Thanks: 72

Math Focus: real analysis, vector analysis, numerical analysis, discrete mathematics
Re: Computing the error function

*nods nods* I was just a bit disappointed because of the trapetzoid rule. It took too much time to compute the results. So. I changed the integrator to sinh-tanh quadrature and now I'm getting accurate enough results quite fast. ^^
fysmat is offline  
March 1st, 2014, 08:17 AM   #8
Global Moderator
 
CRGreathouse's Avatar
 
Joined: Nov 2006
From: UTC -5

Posts: 16,046
Thanks: 938

Math Focus: Number theory, computational mathematics, combinatorics, FOM, symbolic logic, TCS, algorithms
Re: Computing the error function

Quote:
Originally Posted by fysmat
*nods nods* I was just a bit disappointed because of the trapetzoid rule. It took too much time to compute the results. So. I changed the integrator to sinh-tanh quadrature and now I'm getting accurate enough results quite fast. ^^
Yes, PARI/GP uses it internally as well -- I think they have one of the best implementations of double-exponential integration anywhere.
CRGreathouse is offline  
Reply

  My Math Forum > College Math Forum > Applied Math

Tags
computing, error, function



Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error function Sonntag111106 Math Books 1 April 20th, 2013 03:18 AM
Computing Integration of Bessel Function sugakusu Calculus 0 March 26th, 2012 04:19 AM
Error Function? Cookie1 Complex Analysis 1 March 11th, 2012 11:29 PM
error function GoYu Calculus 1 November 2nd, 2011 05:47 AM
Error Function? Cookie1 Applied Math 0 December 31st, 1969 04:00 PM





Copyright © 2019 My Math Forum. All rights reserved.