I am looking for a way to add together multiple mathematical functions before assigning the numerical values for the variables in the equations.
I am doing it this way because I need to optimize my code, and I want to assign different values to the variables each time. An example of what I am trying to do:
f(x, y) = x + 2y
g(x, y) = 3x - y
adds
f(x, y) + g(x, y)
to geth(x, y)
, sof(x, y) + g(x, y) = h(x, y) = 4x + y
Now that I have
h(x, y)
, I need multiple values fromh(x, y)
x = 4; y = 3, h(x, y) = 19
x = 1, y = 0, h(x, y) = 4
etc.
Is this possible? I was trying to create them as strings, add the strings, then remove the quotes to evaluate the sum but this did not work. I am trying to do my method this way because I want to optimize my code. It would help very much if I am able to create my final function before evaluating it (it would be h(x, y)
in this case).
EDIT: I'm doing additions of (e ** (x + y)), so linear solutions using matrices don't work :/