Index: /trunk/Ohana/src/opihi/lib.shell/convert_to_RPN.c
===================================================================
--- /trunk/Ohana/src/opihi/lib.shell/convert_to_RPN.c	(revision 4304)
+++ /trunk/Ohana/src/opihi/lib.shell/convert_to_RPN.c	(revision 4305)
@@ -23,11 +23,12 @@
     type = 0;
     /* unary operations */
-    if (!strcmp (argv[i], "abs"))   { type = 7; goto gotit; }
-    if (!strcmp (argv[i], "int"))   { type = 7; goto gotit; }
-    if (!strcmp (argv[i], "exp"))   { type = 7; goto gotit; }
-    if (!strcmp (argv[i], "ten"))   { type = 7; goto gotit; }
-    if (!strcmp (argv[i], "log"))   { type = 7; goto gotit; }
-    if (!strcmp (argv[i], "ln"))    { type = 7; goto gotit; }
-    if (!strcmp (argv[i], "sqrt"))  { type = 7; goto gotit; }
+    if (!strcmp (argv[i], "abs"))    { type = 7; goto gotit; }
+    if (!strcmp (argv[i], "int"))    { type = 7; goto gotit; }
+    if (!strcmp (argv[i], "exp"))    { type = 7; goto gotit; }
+    if (!strcmp (argv[i], "ten"))    { type = 7; goto gotit; }
+    if (!strcmp (argv[i], "log"))    { type = 7; goto gotit; }
+    if (!strcmp (argv[i], "ln"))     { type = 7; goto gotit; }
+    if (!strcmp (argv[i], "sqrt"))   { type = 7; goto gotit; }
+    if (!strcmp (argv[i], "erf"))    { type = 7; goto gotit; }
 
     if (!strcmp (argv[i], "sinh"))   { type = 7; goto gotit; }
@@ -36,60 +37,59 @@
     if (!strcmp (argv[i], "acosh"))  { type = 7; goto gotit; }
 
-    if (!strcmp (argv[i], "sin"))   { type = 7; goto gotit; }
-    if (!strcmp (argv[i], "cos"))   { type = 7; goto gotit; }
-    if (!strcmp (argv[i], "tan"))   { type = 7; goto gotit; }
-    if (!strcmp (argv[i], "dsin"))  { type = 7; goto gotit; }
-    if (!strcmp (argv[i], "dcos"))  { type = 7; goto gotit; }
-    if (!strcmp (argv[i], "dtan"))  { type = 7; goto gotit; }
-    if (!strcmp (argv[i], "asin"))  { type = 7; goto gotit; }
-    if (!strcmp (argv[i], "acos"))  { type = 7; goto gotit; }
-    if (!strcmp (argv[i], "atan"))  { type = 7; goto gotit; }
-    if (!strcmp (argv[i], "dasin")) { type = 7; goto gotit; }
-    if (!strcmp (argv[i], "dacos")) { type = 7; goto gotit; }
-    if (!strcmp (argv[i], "datan")) { type = 7; goto gotit; }
+    if (!strcmp (argv[i], "sin"))    { type = 7; goto gotit; }
+    if (!strcmp (argv[i], "cos"))    { type = 7; goto gotit; }
+    if (!strcmp (argv[i], "tan"))    { type = 7; goto gotit; }
+    if (!strcmp (argv[i], "dsin"))   { type = 7; goto gotit; }
+    if (!strcmp (argv[i], "dcos"))   { type = 7; goto gotit; }
+    if (!strcmp (argv[i], "dtan"))   { type = 7; goto gotit; }
+    if (!strcmp (argv[i], "asin"))   { type = 7; goto gotit; }
+    if (!strcmp (argv[i], "acos"))   { type = 7; goto gotit; }
+    if (!strcmp (argv[i], "atan"))   { type = 7; goto gotit; }
+    if (!strcmp (argv[i], "dasin"))  { type = 7; goto gotit; }
+    if (!strcmp (argv[i], "dacos"))  { type = 7; goto gotit; }
+    if (!strcmp (argv[i], "datan"))  { type = 7; goto gotit; }
 
     if (!strcmp (argv[i], "lgamma")) { type = 7; goto gotit; }
 
-    if (!strcmp (argv[i], "rnd"))   { type = 7; goto gotit; }
-    if (!strcmp (argv[i], "xramp")) { type = 7; goto gotit; }
-    if (!strcmp (argv[i], "yramp")) { type = 7; goto gotit; }
-    if (!strcmp (argv[i], "ramp"))  { type = 7; goto gotit; }
-    if (!strcmp (argv[i], "zero"))  { type = 7; goto gotit; }
-    if (!strcmp (argv[i], "--"))    { type = 7; goto gotit; }
-    if (!strcmp (argv[i], "not"))   { type = 7; goto gotit; }
-    if (!strcmp (argv[i], "isinf")) { type = 7; goto gotit; }
-    if (!strcmp (argv[i], "isnan")) { type = 7; goto gotit; }
+    if (!strcmp (argv[i], "rnd"))    { type = 7; goto gotit; }
+    if (!strcmp (argv[i], "xramp"))  { type = 7; goto gotit; }
+    if (!strcmp (argv[i], "yramp"))  { type = 7; goto gotit; }
+    if (!strcmp (argv[i], "ramp"))   { type = 7; goto gotit; }
+    if (!strcmp (argv[i], "zero"))   { type = 7; goto gotit; }
+    if (!strcmp (argv[i], "--"))     { type = 7; goto gotit; }
+    if (!strcmp (argv[i], "not"))    { type = 7; goto gotit; }
+    if (!strcmp (argv[i], "isinf"))  { type = 7; goto gotit; }
+    if (!strcmp (argv[i], "isnan"))  { type = 7; goto gotit; }
 
     /* binary operations */
-    if (!strcmp (argv[i], "^"))     { type = 6; goto gotit; }
-    if (!strcmp (argv[i], "@"))     { type = 5; goto gotit; }
-
-    if (!strcmp (argv[i], "<"))     { type = 5; goto gotit; }
-    if (!strcmp (argv[i], ">"))     { type = 5; goto gotit; }
-    if (!strcmp (argv[i], "&&"))    { type = 5; strcpy (argv[i], "A"); goto gotit; }
-    if (!strcmp (argv[i], "||"))    { type = 5; strcpy (argv[i], "O"); goto gotit; }
-    if (!strcmp (argv[i], "=="))    { type = 5; strcpy (argv[i], "E"); goto gotit; }
-    if (!strcmp (argv[i], "!="))    { type = 5; strcpy (argv[i], "N"); goto gotit; }
-    if (!strcmp (argv[i], "<="))    { type = 5; strcpy (argv[i], "L"); goto gotit; }
-    if (!strcmp (argv[i], ">="))    { type = 5; strcpy (argv[i], "G"); goto gotit; }
-    if (!strcmp (argv[i], ">>"))    { type = 5; strcpy (argv[i], "U"); goto gotit; }
-    if (!strcmp (argv[i], "<<"))    { type = 5; strcpy (argv[i], "D"); goto gotit; }
-
-    if (!strcmp (argv[i], "&"))     { type = 5; goto gotit; }
-    if (!strcmp (argv[i], "|"))     { type = 5; goto gotit; }
-
-    if (!strcmp (argv[i], "/"))     { type = 4; goto gotit; }
-    if (!strcmp (argv[i], "*"))     { type = 4; goto gotit; }
-
-    if (!strcmp (argv[i], "+"))     { type = 3; goto gotit; }
-    if (!strcmp (argv[i], "-"))     { type = 3; goto gotit; }
+    if (!strcmp (argv[i], "^"))      { type = 6; goto gotit; }
+
+    if (!strcmp (argv[i], "@"))      { type = 5; goto gotit; }
+    if (!strcmp (argv[i], "/"))      { type = 5; goto gotit; }
+    if (!strcmp (argv[i], "*"))      { type = 5; goto gotit; }
+
+    if (!strcmp (argv[i], "+"))      { type = 4; goto gotit; }
+    if (!strcmp (argv[i], "-"))      { type = 4; goto gotit; }
 	
-    if (!strcmp (argv[i], "("))     { type = 2; goto gotit; }
-    if (!strcmp (argv[i], ")"))     { type = 1; goto gotit; }
+    if (!strcmp (argv[i], "<"))      { type = 3; goto gotit; }
+    if (!strcmp (argv[i], ">"))      { type = 3; goto gotit; }
+    if (!strcmp (argv[i], "&&"))     { type = 3; strcpy (argv[i], "A"); goto gotit; }
+    if (!strcmp (argv[i], "||"))     { type = 3; strcpy (argv[i], "O"); goto gotit; }
+    if (!strcmp (argv[i], "=="))     { type = 3; strcpy (argv[i], "E"); goto gotit; }
+    if (!strcmp (argv[i], "!="))     { type = 3; strcpy (argv[i], "N"); goto gotit; }
+    if (!strcmp (argv[i], "<="))     { type = 3; strcpy (argv[i], "L"); goto gotit; }
+    if (!strcmp (argv[i], ">="))     { type = 3; strcpy (argv[i], "G"); goto gotit; }
+    if (!strcmp (argv[i], ">>"))     { type = 3; strcpy (argv[i], "U"); goto gotit; }
+    if (!strcmp (argv[i], "<<"))     { type = 3; strcpy (argv[i], "D"); goto gotit; }
+    if (!strcmp (argv[i], "&"))      { type = 3; goto gotit; }
+    if (!strcmp (argv[i], "|"))      { type = 3; goto gotit; }
+
+    if (!strcmp (argv[i], "("))      { type = 2; goto gotit; }
+    if (!strcmp (argv[i], ")"))      { type = 1; goto gotit; }
 
   gotit:
     /* choose how to deal with object */
     switch (type) {
-    case 6:  /* unary OPs */
+    case 6:  /* exponentiation */
       /* pop previous, higher operators from OP stack to stack */
       for (j = Nop_stack - 1; (j >= 0) && (op_stack[j].type > type); j--) {
@@ -104,5 +104,5 @@
       Nop_stack ++;
       break;
-    case 7: /* binary OPs */
+    case 7: /* unary OPs */
     case 5: /* binary OPs */
     case 4: 
Index: /trunk/Ohana/src/opihi/lib.shell/evaluate_stack.c
===================================================================
--- /trunk/Ohana/src/opihi/lib.shell/evaluate_stack.c	(revision 4304)
+++ /trunk/Ohana/src/opihi/lib.shell/evaluate_stack.c	(revision 4305)
@@ -75,37 +75,4 @@
       TWO_OP ("S","W",WW_binary);      
       
-      /*
-      if (!strncasecmp (&stack[i - 2].type, "V", 1) && !strncasecmp (&stack[i - 1].type, "V", 1)) 
-	status = VV_binary (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name);
-      if (!strncasecmp (&stack[i - 2].type, "V", 1) && !strncasecmp (&stack[i - 1].type, "S", 1)) 
-	status = VS_binary (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name);
-      if (!strncasecmp (&stack[i - 2].type, "S", 1) && !strncasecmp (&stack[i - 1].type, "V", 1)) 
-	status = SV_binary (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name);
-      if (!strncasecmp (&stack[i - 2].type, "M", 1) && !strncasecmp (&stack[i - 1].type, "V", 1)) 
-	status = MV_binary (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name);
-      if (!strncasecmp (&stack[i - 2].type, "V", 1) && !strncasecmp (&stack[i - 1].type, "M", 1)) 
-	status = VM_binary (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name);
-      if (!strncasecmp (&stack[i - 2].type, "M", 1) && !strncasecmp (&stack[i - 1].type, "M", 1)) 
-	status = MM_binary (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name);
-      if (!strncasecmp (&stack[i - 2].type, "M", 1) && !strncasecmp (&stack[i - 1].type, "S", 1)) 
-	status = MS_binary (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name);
-      if (!strncasecmp (&stack[i - 2].type, "S", 1) && !strncasecmp (&stack[i - 1].type, "M", 1)) 
-	status = SM_binary (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name);
-      if (!strncasecmp (&stack[i - 2].type, "S", 1) && !strncasecmp (&stack[i - 1].type, "S", 1)) 
-	status = SS_binary (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name);
-      if (!strncasecmp (&stack[i - 2].type, "X", 1) && !strncasecmp (&stack[i - 1].type, "X", 1)) 
-	status = XX_binary (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name);
-      */
-
-      /* string op number is not valid 
-      if (!strncasecmp (&stack[i - 2].type, "W", 1) && strncasecmp (&stack[i - 1].type, "W", 1)) {
-	free (tmp_stack.name);
-	return (FALSE);
-      }
-      if (strncasecmp (&stack[i - 2].type, "W", 1) && !strncasecmp (&stack[i - 1].type, "W", 1)) {
-	free (tmp_stack.name);
-	return (FALSE);
-      } */
-
       if (!status) {
 	free (tmp_stack.name);
Index: /trunk/Ohana/src/opihi/lib.shell/stack_math.c
===================================================================
--- /trunk/Ohana/src/opihi/lib.shell/stack_math.c	(revision 4304)
+++ /trunk/Ohana/src/opihi/lib.shell/stack_math.c	(revision 4305)
@@ -1166,4 +1166,5 @@
   if (!strcmp (op, "ln"))    {    *out = log (*M1);           }
   if (!strcmp (op, "sqrt"))  {    *out = sqrt (*M1);          }
+  if (!strcmp (op, "erf"))   {    *out = erf (*M1);           }
 
   if (!strcmp (op, "sinh"))  {    *out = sinh (*M1);          }
@@ -1223,4 +1224,5 @@
   if (!strcmp (op, "ln"))    { for (i = 0; i < Nx; i++, out++, M1++) { *out = log(*M1);          }}
   if (!strcmp (op, "sqrt"))  { for (i = 0; i < Nx; i++, out++, M1++) { *out = sqrt(*M1);         }}
+  if (!strcmp (op, "erf"))   { for (i = 0; i < Nx; i++, out++, M1++) { *out = erf(*M1);          }}
 
   if (!strcmp (op, "sinh"))   { for (i = 0; i < Nx; i++, out++, M1++) { *out = sinh(*M1);        }}
@@ -1289,4 +1291,5 @@
   if (!strcmp (op, "ln"))    { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = log(*M1);          }}
   if (!strcmp (op, "sqrt"))  { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = sqrt(*M1);         }}
+  if (!strcmp (op, "erf"))   { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = erf(*M1);          }}
 
   if (!strcmp (op, "sinh"))  { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = sinh(*M1);         }}
Index: /trunk/Ohana/src/opihi/scripts/test.pro
===================================================================
--- /trunk/Ohana/src/opihi/scripts/test.pro	(revision 4304)
+++ /trunk/Ohana/src/opihi/scripts/test.pro	(revision 4305)
@@ -1,2 +1,35 @@
+
+macro testgauss
+ create x -20 20 0.1
+ set dy = zero(x) + 0.03
+ set X = x - $1
+ set y = $3*exp(-0.5*(X^2/$2^2)) + $4 + 0.1*(rnd(X) - 0.5)
+# set y = $3*exp(-0.5*(X^2/$2^2)) + $4
+ lim x y; clear; box; plot x y -dy dy -x 2 -pt 2
+
+ $C0 = $1+5
+ $C1 = $2-10
+ $C2 = $3
+ $C3 = $4
+
+ vgauss x y dy yf
+end
+
+macro testpoor
+ create x -20 20 0.1
+ set dy = zero(x) + 0.03
+ set X = x - $1
+ set y = 3 + zero(x) + 0.1*(rnd(X) - 0.5)
+# set y = (x + 20)/10 + $4 + 0.1*(rnd(X) - 0.5)
+# set y = $3*exp(-0.5*(X^2/$2^2)) + $4
+ lim x y; clear; box; plot x y -dy dy -x 2 -pt 2
+
+ $C0 = $1
+ $C1 = $2
+ $C2 = $3
+ $C3 = $4
+
+ vgauss x y dy yf
+end
 
 macro testfit
