Other function#

line(x: ndarray, slope: float | None = 1.0, intercept: float | None = 0.0) ndarray[source]#

Computes the y-values of a line given x-values, slope, and intercept.

Parameters:
xnp.ndarray

Input array of values.

slopefloat

The slope of the line.

interceptfloat

The y-intercept of the line.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

linear(x: ndarray, a: float | None = 1.0, b: float | None = 1) ndarray[source]#

Computes the y-values of a linear function given x-values.

Parameters:
xnp.ndarray

Input array of values.

afloat

The coefficient of the linear term (x).

bfloat

The constant term (y-intercept).

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

quadratic(x, a: float | None = 1.0, b: float | None = 1.0, c: float | None = 1.0) ndarray[source]#

Computes the y-values of a quadratic function given x-values.

Parameters:
xnp.ndarray

Input array of values.

afloat

The coefficient of the quadratic term (x^2).

bfloat

The coefficient of the linear term (x).

cfloat

The constant term (y-intercept).

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

cubic(x: ndarray, a: float | None = 1.0, b: float | None = 1.0, c: float | None = 1.0, d: float | None = 1.0) ndarray[source]#

Computes the y-values of a cubic function given x-values.

Parameters:
xnp.ndarray

Input array of values.

afloat

The coefficient of the cubic term (x^3).

bfloat

The coefficient of the quadratic term (x^2).

cfloat

The coefficient of the linear term (x).

dfloat

The constant term (y-intercept).

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

nth_polynomial(x: ndarray, coefficients: list[float]) ndarray[source]#

Evaluate a polynomial at given points.

Parameters:
xnp.ndarray

Input array of values.

coefficientslist of float

Coefficients of the polynomial in descending order of degree. For example, [a, b, c] represents the polynomial ax^2 + bx + c.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.