Suppose I have a Bézier function $f:\mathbb{R}^2\to\mathbb{R}$ with random coefficients:

coefs = Table[{RandomReal[]}, {i, 0, 3}, {j, 0, 3}];    
f = BezierFunction[coefs];

It seems to behave quite well:

Plot3D[f[s, t], {s, 0, 1}, {t, 0, 1}]

graph of $f$

Now I would like to find the maximum of $f$. However,

NMaxValue[f[s, t], {s, t} ∈ Rectangle[{0, 0}, {1, 1}]]

only prints strange output What is wrong and how to fix it?

P.S.: Of course, I could implement Bézier function by myself using Bernstein polynomials etc. But since Mathematica provides this BezierFunction construct, I would like to understand it and be able to use it.


1 Answer 1


The error message tells everything:

"NMaxValue::nnum: "The function value {-0.31322198} is not a number at {s,t} = {0.6524678079740285,0.04524817776440737}""

NMaxValue[First[f[s, t]], {s, t} ∈ Rectangle[{0, 0}, {1, 1}]]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.