Consider the function f(x,y)=x*sqrt(x^2+y^2). Its 1st derivatives w.r.t. x and y are:
df(x,y)/dx = x^2/sqrt(x^2+y^2)+sqrt(x^2+y^2),
df(x,y)/dy = x*y/sqrt(x^2+y^2)
The derivatives are not defined at x=0, y=0, and evaluating them in CasADi will give NaN. However, the limits of the derivatives when x->0, y->0 exist and are equal to 0. Therefore, the 1st derivatives can be made continuous everywhere by defining df(x,y)/d(x,y)=[0,0] at x=0, y=0.
The question is: how to define the function f in CasADi so that the way its derivatives are calculated at the singular point is also defined?