Connect with users of Wolfram technologies to learn, solve problems and share ideas
Mark as an Answer
0 Total Likes
Follow this post
Share this post:
Graphics and Visualization
Weird behaviour of the error function
Mirco Milletarì, NUS
10 years ago
I am experiencing something very strange. As a result of a long calculation I obtain combination of functions of the type
Exp[-b t] Erfc(b x- t/x), where Erfc is the complimentary error function, b and t real parameters (b>0) and x some one dimensional variable.
I order to exhibit some symmetry I would like to use the identity Erfc(z)=1-Erf(z), where now Erf is the error function.
If I plot Erfc(b x- t/x) and 1-Erf(b x- t/x) as a verication, it is clear that things work.
However, plotting Exp[-b t] ( 1-Erf(b x- t/x) ) things get crazy for t<0, where the plot shows some weird oscillatory behaviour and goes rapidly to zero. In the attached picture, the plot shows:
(Red) Exp[-b t] Erfc(b x- t/x)
(Black) Exp[-b t] ( 1 - Erf(b x- t/x) )
So I am kind of puzled here ... am I doing something trivially wrong or is it a bug of Mathematica ?
Any help is more than welcome
Patrick Stevens, University of Cambridge
10 years ago
Notice that the oscillations are of the order 10^-15. Whenever you have weird results from a graph, make sure to check the scale.
Sean Clarke, Wolfram Research
10 years ago
This is caused by the limited accuracy of floating point numbers. It happens in every programmig language on every computer that uses floating point numbers - which is basically all of them. You can read more about floating point numbers and problems like the one you are seeing online. There are many ways of working around this. The simplest is to redefine your function so that it doesn't return such small values, which are prone to problems with floating point numbers. You may also consider using the WorkingPrecision option in Plot to work with a higher precision when doing the calculations.
If you'd still like help, what is the equation you plotted that did this?
Reply to this discussion
in reply to
Community posts can be styled and formatted using the
Tag limit exceeded
Note: Only the first five people you tag will receive an email notification; the other tagged names will appear as links to their profiles.
Add a file to this post
Follow this discussion
Be respectful. Review our
to understand your role and responsibilities.
Wolfram|Alpha Notebook Edition
Volume & Site Licensing
Enterprise Private Cloud
Service Plans Benefits
Wolfram Language Documentation
Wolfram Language Introductory Book
Get Started with Wolfram
Fast Introduction for Programmers
Fast Introduction for Math Students
Webinars & Training
Connected Devices Project
Wolfram Data Drop
Wolfram + Raspberry Pi
. All rights reserved.
Learn how »