Standard .NET generics are not expressive enough to allow such common functions. The problem is that your code can work for anyone that supports the subtraction operator, but .NET generics cannot capture this restriction (they can capture interface restrictions, but not member restrictions).
However, you can use the F # inline functions and statically permitted type parameters , which may have additional restrictions for members. I wrote an article that contains more detailed information about this.
In short, if you mark the function as inline and let the compiler infer the type, then you will get (I removed the explicit mention of the type parameter, as this makes the situation more complicated):
> let inline genericDiff h (f: float -> _) x = > ((f (x + h)) - (f (x - h))) / (h * 2.0);; val inline genericDiff : float -> (float -> ^a) -> float -> float when ^a : (static member ( - ) : ^a * ^a -> float)
Now the compiler used ^a instead of 'a to say that the parameter was resolved statically (during attachment), and he added a constraint that said ^a must have a member - which takes two things and returns a float .
Unfortunately, this is not exactly what you want, because your operator returns Vect3 (and not float as an output compiler). I think the problem is that the compiler wants / operator with two arguments of the same type (while your Vect3 * float ). You can use another operator name (for example, /. ):
let inline genericDiff2 h (f: float -> _) x = ((f (x + h)) - (f (x - h))) /. (h * 2.0);;
In this case, it will work on Vect3 (if you rename scalar division), but it will not work on float easily (although there may be hacks that make this possible - see this answer - although I would not think about this idiomatic F # , and I will probably try to find a way to avoid the need for this). It would be advisable to provide elementary division and pass h as a Vect3 value, perhaps?