MCPcopy Index your code
hub / github.com/numpy/numpy / lagfromroots

Function lagfromroots

numpy/polynomial/laguerre.py:252–305  ·  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 :math:`r_n` are the roots specified in `roots`. If a zero has multiplicity n, then it mus

(roots)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

_fromrootsMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…