HP Forums

Full Version: Chebyshev Approximations of an Analytic Function
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
// program demo_chebyshev HP Prime

// September 12, 2022

// This program demonstrates the procedures for calling
// several Chebyshev subroutines. These subroutines can be
// used to approximate the integral, derivative, and
// function value of a user-defined analytic function.

// This program demonstrates the use of the Chebyshev
// subroutines for evaluating information about

// f(x) = x^2 * (x^2 - 2.0) * sin(x)

// NOTE: current array allocations require maximum degree <= 20

The software allows the user to define a problem using the following inputs coded at the beginning of the main program.

// maximum degree of the chebyshev approximation

ndeg := 15;

// lower limit of the evaluation interval

xlower := 1.0;

// upper limit of the evaluation interval

xupper := 2.0;

// number of terms in the chebyshev approximation

nterms := 10;

// x argument for evaluation

x := 1.5;

The following is the source code for the user-defined function for this example. This is where the user should define his or her function of interest.

user_func(x)

// user-defined function subroutine

///////////////////////////////////

BEGIN

LOCAL fx;

fx := (x * x) * (x * x - 2.0) * sin(x);

return fx;

END;
Reference URL's