A two-dimensional function is a function that takes two input variables, e.g. x and y.
Test Function
We can use the same x^2 function and scale it up to be a two-dimensional function; for example:
f(x, y) = x^2 + y^2
This has an optimal value with an input of [x=0.0, y=0.0], which equals 0.0.
The example below implements this objective function and evaluates a single input.
example of a 2d objective function
objective function
def objective(x, y):
return x2.0 + y2.0
evaluate inputs to the objective function
x = 4.0
y = 4.0
result = objective(x, y)
print(‘f(%.3f, %.3f) = %.3f’ % (x, y, result))
Running the example evaluates the point [x=4, y=4], which equals 32.
f(4.000, 4.000) = 32.000