The Case of the Counterfeit Error Function

T. J. Fairclough   C.Math.  MIMA

Institut Teknologi Brunei


Chapter 1: Breakfast at Baker Street

Mrs. Hudson was busy serving breakfast in the dining room when Sherlock Holmes strode in.  A worried look sullied his noble countenance and he was clutching in his hand what appeared to be an important letter bearing an impressive seal.


"Momentous news Watson, my dear friend, this letter is a top secret report just arrived by special messenger from our old friend Inspector Lestrade of Scotland Yard.   He tells me that some fiendish devil has been counterfeiting the Error function with a shoddy imitation and there's a grave danger it could damage the environment if it spreads.  It's vital that we put a stop to it as soon as we can."


I looked at my friend's troubled features as he extracted from the envelope two sheets of tracing paper which he closely perused for a while before carefully placing them side-by-side in front of me on the tablecloth.   "It's alright Watson" he sighed with relief after a few moments study, "The Yard appear to have overstated the case as usual.  As you can see (Figure 1) the graph on the left is the real error function and the one on the right is nothing more than our old friend the hyperbolic tangent.  Not even a rank amateur could get those two mixed up, although I must admit there's more than a passing resemblance to the untrained eye now I come to look at it though. Perhaps I'd better investigate it a bit closer just to quantify matters". 

Fig. 1.The graph on the left is  and on the right y = tanh(x)


Sherlock tapped away on the PC keyboard for a few minutes before turning to me with an excited look on his face.  "It's really quite interesting Watson, but the integral of the squared difference between Erf(x) and tanh(x) over the infinite range is surprisingly small.  I make it just 0.01488.  Mind you, when the curves are superimposed (Figure 2) you could drive a hansom cab through those gaps.  Fortunately it's not a good enough forgery to be really useful to anybody and our friends who print the Erf tables needn't worry themselves too much on that score I feel sure."

Fig.2. The graphs of y = Erf(x) and y = tanh(x) when superimposed.  Note the big gaps referred to by Holmes.


Chapter II: Lestrade Gets the Message

At that very moment the door sprang open with a loud bang and Mrs. Hudson bustled in followed closely at her heels by a flushed and excited Inspector Lestrade.   "Thank goodness I've caught you in Holmes, the case has taken a decided turn for the worse, Look!"


Dramatically Lestrade drew from his pocket another sheet of tracing paper similar to the two already on the table and handed it to Holmes with a flourish.  In silence Sherlock took it from him and superimposed it on the real Error function (figure 3). Holding them both up to the light he whistled softly and then declared excitedly  "My oath, Watson, but it's the dead spit."  (In the heat of the moment this coarse lapse into the vernacular was surely understandable and presumably due to a recent case that necessitated frequent trips to Southend-On-Sea in disguise as a common applied mathematician).  We all gazed in awe at the uncanny statement scrawled in an unknown hand on the top of the new arrival

                   Fig. 3.  The superimposed functions y = Erf(x) and y = tanh(ax+bx3).  Notice that the gaps have now disappeared!


Sherlock chewed thoughtfully on a mouthful of the Pythagorean toast before exclaiming "By Harry! I see it all clearly now Watson, the cunning devil has minimised the squared difference by using two adjustable parameters, a and b, and he's closed those gaps quite convincingly.  In fact I suspect that this imposter function will never be more than plus or minus 0.06% in error!  Clearly some further investigation is urgently called for."


 Several tense minutes passed before Sherlock Holmes finally stood up to leave the PC and stride over to the mantlepiece in the direction of the Persian slipper.  Lighting his pipe Holmes looked up to the ceiling and said " The clever devil has realised that there's no point in going beyond the cubic power.  The fit is actually worsened if the fifth or the seventh powers are included.  We're obviously dealing with a master here Watson.  It can be none other than that devilish Napoleon of crime Professor Moriarty himself.  His treatise on the Binomial Theorem at the age of 21 presaged a brilliant career as a mathematician before he turned his fiendish mind to dastardly crime.   I'm already hot on his trail over that Nongentium Dome business and this latest piece of villainy is clearly an attempt to divert me from it.


Leaning forward and with a worried and thoughful look Lestrade said at last "This is terrible news, Holmes, if this gets out it means anybody with a non-programmable calculator will be able to evaluate the error function quite accurately just by tapping on a few keys without doing any numerical integration or even a power series summation.  Every skinflint in town with a tanh key will be a threat, even kids in the classroom will have it.  The only thing we can be thankful for is that there's still no way of easily getting at the inverse."



Chapter III: Mrs. Hudson Delivers the Inverse on a Plate

For the second time that morning the door flew open with a bang, this time to admit an increasingly flustered Mrs. Hudson bearing a silver tray on top of which was perched a letter.  "This has just come for you Mr. Holmes, it was delivered by a rough looking fellow.  He refused to leave his name but I noticed he was wearing one of those IMA ties you warned me about."


At this latest news and with trembling fingers Sherlock inspected the envelope, closely scrutinising the hand writing and holding the letter up to his nose. " This envelope has few minor points of interest, Watson.  It was clearly written by a left-hander during a train journey, see here the way the lamdas in the address are done backwards and notice those jerking breaks in the otherwise smooth hand-writing.   Moriarty is left-handed and I happen to know he is currently travelling abroad on the Continent in a sly scheme to promote the Euro; the smell of chocolate on the envelope is quite unmistakable. "


Holmes then opened the envelope and withdrew from it a single sheet of paper headed "The Inverse" followed by the stark lines of text 



Written underneath were the chilling words "I'll send it all to 'Mathematics Today' if you don't lay off .'"  A stunned silence descended on the room as we digested this latest piece of dramatic news.  The silence was broken only by Holmes saying "We're done for Watson.   If this is what I think it is then the inverse error function can also be closely got by just a few more taps on the keyboard, I'd better test it out right away, there's not a moment to lose."


The PC in the corner was our old Babbage Three (cwt.) CDLXXXVI with the initials "VR" burned into its monitor display.  This had occurred accidentally some time back when that popular screen saver had unavoidably been left switched continuously on for several months when Sherlock was away in Switzerland on the heels of Moriarty during a previous adventure chronicled elsewhere1.    Impatiently Holmes fired up his latest version of Mathcad 1900 Professional and tapped away on the keyboard.  After a few moments he turned to Lestrade to say thoughtfully.  "This proxy inverse is pretty accurate but there's hope for us yet.  If Moriarty's inverse error function is any good and we give it for an argument the error function itself we should always come back to where we started.   You can see (Figure 4) it's only really good between x equals  plus and minus two where the maximum error is (illegible).  Unfortunately for us though, both the imposter and its inverse also seem to work very well even with the complex arguments z = x + jy. With x running from 0 to 3 and y from 0 to 2 the maximum error is only (illegible percent ) for the forward function and (illegible percent) for the inverse.  If this gets out we're in for it alright, bad functions drive out good, the Error function market will collapse and the Java programmers will soon have it wrapped up in a simple one-liner method before you can say  'ArrayIndexOutOfBoundsException' "


Fig. 4..  If Moriarty's inverse error function were perfect both graphs should exactly coincide with the straight line y = x.


Chapter IV: His Last Bow.

Pulling himself up to his full height and with a somber tread Holmes walked over to his foot-locker to pull out the bulls-eye lantern and his life-preserver. "The game's afoot Watson!  There's nothing for it but for me to find that scoundrel Moriarty as soon as possible. I'll simply have to find a way to steal this dangerous formula from him and put a stop to his evil mischief once and for all.  I leave for Brussels immediately.  If you don't hear from me in three weeks you'd better check the pages of "Mathematics Today. Farewell dear friend."  With those portentous words and a last bow he turned to leave. The door slowly closed behind his tall figure and he was gone, forever?


 With sincere apologies to the memory of Sir Arthur Conan Doyle.




1. " The Memoirs of Sherlock Holmes: The Final Problem", Doyle, Arthur Conan, Sir,