2
$\begingroup$

The question is probably clear in the title. In many of my applications mostly computer vision, I might not have the closed-form or analytical form of f (a multivariable function).

It's calculated numerically instead and in general, non-linear, without guarantee of smoothness or differentiable. Since it includes:

function f = nlfun(x)

    if .. 
    ..
    else
    ..
    end

    switch ..
    case 1:
       f = nonlinear_function
    end

How may I investigate this f=nlfun(x) characteristics e.g. smoothness, differentiable...? and finally, calculate its Jacobian?

Thank you

$\endgroup$
1
  • $\begingroup$ if my question is not appropriate for Math forum, please move it to a suitable one. Is it computer science sector? $\endgroup$ – Shawn Le Mar 27 '14 at 17:47
6
$\begingroup$

I don't think it's possible to tell if a function is continuous/differentiable/smooth without knowing the function definition, i.e. its code. I don't even know how these concepts are defined in finite precision math. After all, the set of floating point numbers in a computer is not continuous.

On the other hand, it is easy to calculate the Jacobian of a function numerically. A Jacobian is a bunch of partial derivatives, and you can calculate them with finite differences. For example:

$$\mathbf{F}(\mathbf{x}) = u(x, y, z) \mathbf{i} + v(x, y, z)\mathbf{j} + w(x, y, z)\mathbf{k}$$

$$J = \begin{bmatrix} \dfrac{\partial u}{\partial x} & \dfrac{\partial u}{\partial y} & \dfrac{\partial u}{\partial z} \\ \dfrac{\partial v}{\partial x} & \dfrac{\partial v}{\partial y} & \dfrac{\partial v}{\partial z} \\ \dfrac{\partial w}{\partial x} & \dfrac{\partial w}{\partial y} & \dfrac{\partial w}{\partial z} \end{bmatrix}$$

$$\frac{\partial u}{\partial x} \approx \frac{u(x+h, y, z) - u(x-h, y, z)}{2h}$$

$h$ is a small number like $10^{-3}$. If it is too big, you will get big truncation errors. If it is too small, you will get big roundoff errors. Usually it must be calibrated by trial and error until you get good results.

Often what you need is the Jacobian determinant, which can be calculated from the above matrix.

When using finite differences, you don't need to know the function definition. You just need to call it a couple of times with different parameters.

$\endgroup$
3
  • 1
    $\begingroup$ Thank you! at some points you've answered 3 of my problems: 1) using finite difference (there are several formulation for this I guess), 2) h is chosen in a trial and error manner, 3) another confirmation about no necessity of function's definition (simply sometimes it's not in closed-form) $\endgroup$ – Shawn Le Mar 28 '14 at 7:33
  • 1
    $\begingroup$ Also, smoothness and differentiability of such function is hard or impossible to check $\endgroup$ – Shawn Le Mar 28 '14 at 7:36
  • 2
    $\begingroup$ @ShawnLe, If you want to check smoothness, you can do FFT, if it has high-frequency energy, it means it has high oscillation. In this way, it is not very smooth $\endgroup$ – ytyyutianyun May 16 '18 at 19:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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