polynomial: Polynomial Class

View source: R/polynomial.R

derive.polynomialR Documentation

Polynomial Class

Description

Methods for creating, evaluating, manupulating and displaying polynomial functions.

Usage

## S3 method for class 'polynomial'
derive(x)

## S3 method for class 'spline'
derive(x)

## S3 method for class 'polynomial'
integrate(x)

## S3 method for class 'spline'
integrate(x, n = 1)

polynomial(beta)

## Default S3 method:
polynomial(beta)

## S3 method for class 'polynomial'
x + y

## S3 method for class 'polynomial'
x - y

## S3 method for class 'polynomial'
x * y

## S3 method for class 'polynomial'
print(x)

## S3 method for class 'polynomial'
coef(x)

Arguments

x, y

Polynomial object.

beta

Numeric vector of polynomial coefficients. First element is the constant coefficient, the second element is the linear coefficient, the third is the quadratic coefficient, etc...

Methods (by class)

  • polynomial(default): Polynomial object creation and evaluation.

Methods (by generic)

  • derive(polynomial): Polynomial derivation method.

  • integrate(polynomial): Polynomial integration method.

  • + : Polynomial unary and binary addition operator.

  • - : Polynomial unary and binary substraction operator.

  • * : Polynomial multiplication operator.

  • print(polynomial): Polynomial print method.

  • coef(polynomial): Polynomial print method.

Functions

  • derive(spline): Spline derivation method.

  • integrate(spline): Spline integration method.

Examples

p1 <- polynomial(1:3)    # Create polynomial 1 + 2*x + 3*x^2.
p2 <- polynomial(0:5)    # Create polynomial x + 2*x^2 + 3*x^3 + 4*x^4 + 5*x^5.

# Evaluation:
x <- 1:10
polynomial(1)(x)        # Constant function.
polynomial(c(1,0,2))(x) # Quadratic 1 + 2*x^2.
p1(x)                   # Evaluate 'p1' at 'x'.
(p1 + p2)(x)            # Evaluate the sum of 'p1' and 'p2' at 'x'.
(p1 - p2)(x)            # Evaluate the difference of 'p1' and 'p2' at 'x'.

TobieSurette/gulf.stats documentation built on Jan. 4, 2023, 4:19 p.m.