3 ms·
> Does J have a notion of the relationship between certain functions and their inverse? Yes. Many built-in words have inverses assigned, and you can assign inv
by klibertp 6y ago
> Does J have a notion of the relationship between certain functions and their inverse?
Yes. Many built-in words have inverses assigned, and you can assign inverse functions to your own words with :. https://code.jsoftware.com/wiki/Vocabulary/codot https://code.jsoftware.com/wiki/Vocabulary/codot
EDIT: and here's a table with predefined inverses: https://code.jsoftware.com/wiki/Vocabulary/Inverses https://code.jsoftware.com/wiki/Vocabulary/Inverses
- henrikeh 6y agoThat can definitely be implemented in Matlab with the symbolic math toolbox. But interesting nonetheless.
- patrec 6y agoI have used matlab quite a bit in the past, but not the symbolic math toolbox: can you make a "normal" function definition symbolic retroactively? I thought you need to define the function explicitly as symbolic to start with, or am I wrong?
- henrikeh 6y agoYes, the symbolic functions can be made "retroactively". The various conventional functions are overloaded with the symbolic input. >> syms x >> f = @(x) log(sqrt(x)).^2 f = function_handle with value: @(x)log(sqrt(x)).^2 >> f(x) ans = log(x^(1/2))^2 >> finverse(f(x)) ans = exp(2*x^(1/2)) And to implement under: function u = under(f, g) syms x g_inv = matlabFunction(finverse(g(x))); u = @(x) g_inv(f(g(x))); end
- patrec 6y agoSo if you have odddouble.m with function y=odddouble(a,b) y=2*x+1 endfunction you can do >>> h = under(@(x) 1/x, odddouble) >>> h(3) ? If so, yeah, I agree you can implement under in matlab (as long as you have the symbolic toolbox as well); in which case it's probably one of very few non-CAS systems where you can define it.
- henrikeh 6y agoJust tested it and it worked fine. Note that your function takes too many parameters in its definition and that functions can't be passed as parameters by name. It is definitely not as elegant as the built-in facility in J, but definitely doable and usable in Matlab. In fact, I think any language with flexible enough function overloading should be able to implement such a feature.