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

Function lagfromroots

numpy/polynomial/laguerre.py:251–304  ·  view source on GitHub ↗

Generate a Laguerre series with given roots. The function returns the coefficients of the polynomial .. math:: p(x) = (x - r_0) * (x - r_1) * ... * (x - r_n), in Laguerre form, where the `r_n` are the roots specified in `roots`. If a zero has multiplicity n, then it must appe

(roots)

Source from the content-addressed store, hash-verified

249
250
251def lagfromroots(roots):
252 """
253 Generate a Laguerre series with given roots.
254
255 The function returns the coefficients of the polynomial
256
257 .. math:: p(x) = (x - r_0) * (x - r_1) * ... * (x - r_n),
258
259 in Laguerre form, where the `r_n` are the roots specified in `roots`.
260 If a zero has multiplicity n, then it must appear in `roots` n times.
261 For instance, if 2 is a root of multiplicity three and 3 is a root of
262 multiplicity 2, then `roots` looks something like [2, 2, 2, 3, 3]. The
263 roots can appear in any order.
264
265 If the returned coefficients are `c`, then
266
267 .. math:: p(x) = c_0 + c_1 * L_1(x) + ... + c_n * L_n(x)
268
269 The coefficient of the last term is not generally 1 for monic
270 polynomials in Laguerre form.
271
272 Parameters
273 ----------
274 roots : array_like
275 Sequence containing the roots.
276
277 Returns
278 -------
279 out : ndarray
280 1-D array of coefficients. If all roots are real then `out` is a
281 real array, if some of the roots are complex, then `out` is complex
282 even if all the coefficients in the result are real (see Examples
283 below).
284
285 See Also
286 --------
287 numpy.polynomial.polynomial.polyfromroots
288 numpy.polynomial.legendre.legfromroots
289 numpy.polynomial.chebyshev.chebfromroots
290 numpy.polynomial.hermite.hermfromroots
291 numpy.polynomial.hermite_e.hermefromroots
292
293 Examples
294 --------
295 >>> from numpy.polynomial.laguerre import lagfromroots, lagval
296 >>> coef = lagfromroots((-1, 0, 1))
297 >>> lagval((-1, 0, 1), coef)
298 array([0., 0., 0.])
299 >>> coef = lagfromroots((-1j, 1j))
300 >>> lagval((-1j, 1j), coef)
301 array([0.+0.j, 0.+0.j])
302
303 """
304 return pu._fromroots(lagline, lagmul, roots)
305
306
307def lagadd(c1, c2):

Callers

nothing calls this directly

Calls 1

_fromrootsMethod · 0.80

Tested by

no test coverage detected