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

Function hermfromroots

numpy/polynomial/hermite.py:257–310  ·  view source on GitHub ↗

Generate a Hermite 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 Hermite form, where the :math:`r_n` are the roots specified in `roots`. If a zero has multiplicity n, then it must

(roots)

Source from the content-addressed store, hash-verified

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