Description Usage Arguments Details Value Examples

View source: R/expandFunctions.R

orthopolynom can be used to generate special functions, but for expansion they should be modified. As of this writing, orthopolynom generates polynomials for Chebyshev, Hermite, Legendre and many other functions, their integrals and derivatives, and more.

1 | ```
polywrapper(basePoly = orthopolynom::chebyshev.t.polynomials, kMax = 0)
``` |

`basePoly` |
A polynomial list from orthopoly |

`kMax` |
Integer. The maximum order of the function generated. |

The function polywrapper does 2 things:

Generate functions from polynomial coefficients.

Uses x as the 1st argument, and the order as the second; this means the generated functions can be used in eOuter and eMatrixOuter.

The functions so generated can be used as simple special functions, as well as being useful in feature building.

Since the coefficients from orthopolynom are generated by recursion, an upper limit of the function order needs to be set when calling polywrapper. This is the main limitation of polywrapper. Fortunately, since the functions are compactly stored, kMax can be set quite high if desired. Note that usually the kMax is known, and is relatively small.

NB: The input x may need to be normalized. orthopolynom has the function scaleX for just such a purpose.

Function which is compatible with eOuter and eMatrixOuter

1 2 3 4 5 6 7 8 9 10 11 12 | ```
# Generate a Chebyshev function of the form
# chebyFUN(x,k), where x is the input and k is the order.
# In this case, k must be no more than 5 (since that
# is the value passed to kMax), although it is
# easy to set this to a higher order if desired.
chebyFUN <- polywrapper(basePoly=orthopolynom::chebyshev.t.polynomials,
kMax=5)
# Now the function chebyFUN
# can be used as any other function:
x <- seq(-1,+1,0.01)
plot(x,chebyFUN(x,5),type="l")
eOuter(seq(-1,+1,0.01),0:3,chebyFUN)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.