Physics Tool: Error Function Value via Command Line

Having reinstalled my computer recently, I haven't gotten around to putting all my software (such as Maple) back on. So when I realized I needed to know the value of the error function at 1.0, I was most annoyed to waste 5 minutes searching the web for it. Deciding that I never want to do that again, I wrote the following rather simple tool.

/* Get Values of the Error Function... */
/* Compile: gcc -lm -o erf erf.c       */
/* Syntax (erf of 1.571): ./erf 1.571  */
/* Miles V. Aronnax, 2008 Oct 2        */
#include <stdio.h>
#include <math.h>

int main(int argc, char *argv[]) {
  float xvar;
  sscanf(argv[1], "%f", &xvar);
  printf("Erf(%f) = %f.\n", xvar, erf(xvar));
  return 0;
}

Yes, that is it. Just copy the code into a file called erf.c, compile as noted, and you too can get error function values from the command line. By the way, the erf(1) is 0.842701.

Oh yeah, if you have Maple, you can get the value of the error function by typing evalf(erf(1.571)). I'm afraid I don't know the command for MATLAB or Mathematica off hand, but I doubt it is any harder.