John Randall asked:
> Given that the xth Chebyshev polynomial evaluated at y can be written
> cos x*arccos y
> is there a way to write it using inverses?
Yes, because cos^:_1 is arccos (with cos =: 2&o. ). For example:
cos =: 2&o.
cos^:_1 cos 3.14159
3.14159
But, in this case, ^:_1 is overkill, because there is already an o.
function code for arccos. The mnemonic is that x&o. is inverted by (-x)&o.
. Since cos is 2&o. arccos is _2&o. .
Consequently, I'd be tempted to write:
cheb0 =: 2 _2 */ .o. ,
If you were asking if there's a way to write this with &. (under), I think
the answer is no. Under is used when you want to transform an input, apply a
function to the transformed input, and invert the transformation. The key here
is that the inverse is applied to the output of the function.
But in this case, the transformation and its inverse are being applied to two
different things, both preceding the application of the function. So under is
not applicable [1].
Which doesn't we can't still use J's powering ability:
cheb1 =: 1 _1 */ .(2&o."0) ,
or perhaps more clearly:
cos =: 2&o."0
cheb1 =: 1 _1 */ .cos ,
Note that we've rewritten the definition entirely in terms of powers of cos;
nowhere is arccos explicitly mentioned (in English: cheb1 is the product of
cos^:1 applied to x and cos^:_1 applied to y ).
Does that help?
-Dan
[1] A similiar sentiment applies to & (compose). Varations on the theme of
*&o. will not work (or at least I can't think of a way).
This is because in u&v the /same/ function will to be applied to both inputs
(i.e. v ), and in the case of Chebyshev, we want two separate functions (
2&o. vs _2&o. ). Of course, you could go through contortions like:
cheb2 =:*&(> o.~ 2*_1^L.) <
but at some point this becomes silly.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm