Index: includes/math-expr.inc
===================================================================
--- includes/math-expr.inc	(revision 450)
+++ includes/math-expr.inc	(working copy)
@@ -218,15 +218,14 @@
                     $fnn = $matches[1]; // get the function name
                     $arg_count = $stack->pop(); // see how many arguments there were (cleverly stored on the stack, thank you)
                     $output[] = $stack->pop(); // pop the function and push onto the output
-                    if (in_array($fnn, $this->fb)) { // check the argument count
-                        if($arg_count > 1)
-                            return $this->trigger("too many arguments ($arg_count given, 1 expected)");
-                    } elseif (array_key_exists($fnn, $this->f)) {
-                        if ($arg_count != count($this->f[$fnn]['args']))
-                            return $this->trigger("wrong number of arguments ($arg_count given, " . count($this->f[$fnn]['args']) . " expected)");
-                    } else { // did we somehow push a non-function on the stack? this should never happen
-                        return $this->trigger("internal error");
-                    }
+                    if (!in_array($fnn, $this->fb)){ 
+						if (array_key_exists($fnn, $this->f)) {
+							if ($arg_count != count($this->f[$fnn]['args']))
+								return $this->trigger("wrong number of arguments ($arg_count given, " . count($this->f[$fnn]['args']) . " expected)");
+						} else { // did we somehow push a non-function on the stack? this should never happen
+								return $this->trigger("internal error");
+						}
+					}
                 }
                 $index++;
             //===============
@@ -324,10 +323,15 @@
             } elseif (preg_match("/^([a-z]\w*)\($/", $token, $matches)) { // it's a function!
                 $fnn = $matches[1];
                 if (in_array($fnn, $this->fb)) { // built-in function:
-                    if (is_null($op1 = $stack->pop())) return $this->trigger("internal error");
+					if ($stack->count>1){//Support more than 2 arguments
+						//Pop all elements to build op1
+						$op1 = implode(',', array_slice($stack->stack, 0, $stack->count));
+						$stack->count = 0;//Reset counter/Empty stack
+					}
+                    elseif (is_null($op1 = $stack->pop())) return $this->trigger("internal error");
                     $fnn = preg_replace("/^arc/", "a", $fnn); // for the 'arc' trig synonyms
                     if ($fnn == 'ln') $fnn = 'log';
-                    eval('$stack->push(' . $fnn . '($op1));'); // perfectly safe eval()
+					eval('$stack->push(' . $fnn . '('.$op1.'));'); // perfectly safe eval()
                 } elseif (array_key_exists($fnn, $this->f)) { // user function
                     // get args
                     $args = array();
