Yes - this is possible using dynamically generated node groups similar to Cycles Materials Math node with more than two inputs, coupled with a python script to parse the entered expression. Since the expression is built up using standard Maths nodes it is effectively just as efficient as if you had built the nodes manually - but with the ease of being able to simply enter the expression and let Blender do the hard work.
This can be achieved by installing the Maths Expression add-on available here, developed originally for Recreating Mandelbulbs with math nodes - simply download the .ZIP file, open User Preferences, and in the Add-ons tab select 'Install Add-on from file...' and point it at the .ZIP. Enable the add-on (by enabling the checkbox) and Save User Settings to make it automatically enabled when loading Blender.
You should now have a new 'Custom Nodes' menu in the Add menu of the Node Editor and within that a new 'Dynamic Maths Expression' option. Selecting this will add a node similar to the following :
Entering an expression into the Expression field will automatically build the internal nodes to implement that expression, automatically addin Input and Output sockets as required.
For example, entering a+b+c
will result in the following node and internal structure :
Similarly you can enter much more complicated expressions such as calculating the distance of an x, y, z vector as (x*x+y*y+z*z)**0.5
:
Note that you can implement multiple expressions simultaneously by entering each expression, separated by commas. You can also assign a name to each expression using the '=' operator. For example, entering the expression Distance=(x*x+y*y+z*z)**0.5,Maximum=max(x,max(y,z)),Average=(x+y+z)/3
will produce the following node providing all three results :
In the comments to @zeffii's answer it mentions being able to implement conditional statements. This can be achieve by making use of the values of True and False being 1 and 0 respectively - by multiplying a statement by a conditional we can effectively mask it where the conditional is False and only include it where it is True, summing the result of multiple utually exclusive conditions. For example, to implement the ternary statement x*3 if x<0 else x*5
we could simply write :
(x*3)*(x<0) + (x*5)*(x>=0)
Note that the first term will be zero if x>=0 while the second term will be zero when x<0.
The add-on successfully interprets all the main operators (+, -, *, /), power (**), comparators (<, <=, >, >=, ==), and functions sin(), cos(), tan(), asin(), acos(), atan(), atan2(), max(), min(), log(), round(), mod(), abs(), as well as brackets to override the natural precedence and '=' as a means of assigning a label to an output (rather than the default of 'Value').
Note that the generated node tree is available via the Group node - as for any other node group - with a name starting 'DynamicMathsExpression'. The 'internal' nodes can be copied and pasted outside the group so that they can be used independent of the add-on.