3D Grapher - Function input problem

I’m creating a 3D Grapher, but i have a problem. how can i allow user to input a function (eg. z=x^2+y^2). One way would be to input it as a string and then write function that will get x and y values, replace x, y in function with them and then somehow solve it. but it would be pretty hard. is there another way to do that?
P.S C# code would be better for me.

Hmm, i think it really depends on functions variety. If input function amount is limited, then you could create a list of functions and then just allow the users to input those amount numbers in specific fields (in z, y and x slots). So pretty much you code what each function does and how its drawn, you just allow the user to input pure numbers.

If you want to allow the user input pretty much any type of these functions, then i believe there is no other way then reading whole information as string and then process it that way.