10.9 Functions Producing FunctionsΒΆ

In ugUserMake , you learned how to use the operation function to create a function from symbolic formulas. Here we introduce a similar operation which not only creates functions, but functions from functions.

The facility we need is provided by the package MakeUnaryCompiledFunction(E,S,T). MakeUnaryCompiledFunction This package produces a unary (one-argument) compiled function from some symbolic data generated by a previous computation. MakeBinaryCompiledFunction is available for binary functions. MakeBinaryCompiledFunction The E tells where the symbolic data comes from; the S and T give FriCAS the source and target type of the function, respectively. The compiled function produced has type S-> T. To produce a compiled function with definition p(x)==expr, call compiledFunction(expr,x) from this package. The function you get has no name. You must to assign the function to the variable p to give it that name.

Do some computation.

(x+1/3)^5

Convert this to an anonymous function of x. Assign it to the variable p to give the function a name.

p := compiledFunction(%,x)$MakeUnaryCompiledFunction(POLY FRAC

INT,DFLOAT,DFLOAT)

Apply the function.

p(sin(1.3))

For a more sophisticated application, read on.