MCPcopy Create free account
hub / github.com/numpy/numpy / chebval

Function chebval

numpy/polynomial/chebyshev.py:1094–1175  ·  view source on GitHub ↗

Evaluate a Chebyshev series at points x. If `c` is of length `n + 1`, this function returns the value: .. math:: p(x) = c_0 * T_0(x) + c_1 * T_1(x) + ... + c_n * T_n(x) The parameter `x` is converted to an array only if it is a tuple or a list, otherwise it is treated as a sc

(x, c, tensor=True)

Source from the content-addressed store, hash-verified

1092
1093
1094def chebval(x, c, tensor=True):
1095 """
1096 Evaluate a Chebyshev series at points x.
1097
1098 If `c` is of length `n + 1`, this function returns the value:
1099
1100 .. math:: p(x) = c_0 * T_0(x) + c_1 * T_1(x) + ... + c_n * T_n(x)
1101
1102 The parameter `x` is converted to an array only if it is a tuple or a
1103 list, otherwise it is treated as a scalar. In either case, either `x`
1104 or its elements must support multiplication and addition both with
1105 themselves and with the elements of `c`.
1106
1107 If `c` is a 1-D array, then `p(x)` will have the same shape as `x`. If
1108 `c` is multidimensional, then the shape of the result depends on the
1109 value of `tensor`. If `tensor` is true the shape will be c.shape[1:] +
1110 x.shape. If `tensor` is false the shape will be c.shape[1:]. Note that
1111 scalars have shape (,).
1112
1113 Trailing zeros in the coefficients will be used in the evaluation, so
1114 they should be avoided if efficiency is a concern.
1115
1116 Parameters
1117 ----------
1118 x : array_like, compatible object
1119 If `x` is a list or tuple, it is converted to an ndarray, otherwise
1120 it is left unchanged and treated as a scalar. In either case, `x`
1121 or its elements must support addition and multiplication with
1122 themselves and with the elements of `c`.
1123 c : array_like
1124 Array of coefficients ordered so that the coefficients for terms of
1125 degree n are contained in c[n]. If `c` is multidimensional the
1126 remaining indices enumerate multiple polynomials. In the two
1127 dimensional case the coefficients may be thought of as stored in
1128 the columns of `c`.
1129 tensor : boolean, optional
1130 If True, the shape of the coefficient array is extended with ones
1131 on the right, one for each dimension of `x`. Scalars have dimension 0
1132 for this action. The result is that every column of coefficients in
1133 `c` is evaluated for every element of `x`. If False, `x` is broadcast
1134 over the columns of `c` for the evaluation. This keyword is useful
1135 when `c` is multidimensional. The default value is True.
1136
1137 .. versionadded:: 1.7.0
1138
1139 Returns
1140 -------
1141 values : ndarray, algebra_like
1142 The shape of the return value is described above.
1143
1144 See Also
1145 --------
1146 chebval2d, chebgrid2d, chebval3d, chebgrid3d
1147
1148 Notes
1149 -----
1150 The evaluation uses Clenshaw recursion, aka synthetic division.
1151

Callers 1

chebintFunction · 0.85

Calls 2

astypeMethod · 0.80
reshapeMethod · 0.80

Tested by

no test coverage detected