Generate a Legendre 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 Legendre form, where the :math:`r_n` are the roots specified in `roots`. If a zero has multiplicity n, then it mus
(roots)
| 266 | |
| 267 | |
| 268 | def legfromroots(roots): |
| 269 | """ |
| 270 | Generate a Legendre series with given roots. |
| 271 | |
| 272 | The function returns the coefficients of the polynomial |
| 273 | |
| 274 | .. math:: p(x) = (x - r_0) * (x - r_1) * ... * (x - r_n), |
| 275 | |
| 276 | in Legendre form, where the :math:`r_n` are the roots specified in `roots`. |
| 277 | If a zero has multiplicity n, then it must appear in `roots` n times. |
| 278 | For instance, if 2 is a root of multiplicity three and 3 is a root of |
| 279 | multiplicity 2, then `roots` looks something like [2, 2, 2, 3, 3]. The |
| 280 | roots can appear in any order. |
| 281 | |
| 282 | If the returned coefficients are `c`, then |
| 283 | |
| 284 | .. math:: p(x) = c_0 + c_1 * L_1(x) + ... + c_n * L_n(x) |
| 285 | |
| 286 | The coefficient of the last term is not generally 1 for monic |
| 287 | polynomials in Legendre form. |
| 288 | |
| 289 | Parameters |
| 290 | ---------- |
| 291 | roots : array_like |
| 292 | Sequence containing the roots. |
| 293 | |
| 294 | Returns |
| 295 | ------- |
| 296 | out : ndarray |
| 297 | 1-D array of coefficients. If all roots are real then `out` is a |
| 298 | real array, if some of the roots are complex, then `out` is complex |
| 299 | even if all the coefficients in the result are real (see Examples |
| 300 | below). |
| 301 | |
| 302 | See Also |
| 303 | -------- |
| 304 | numpy.polynomial.polynomial.polyfromroots |
| 305 | numpy.polynomial.chebyshev.chebfromroots |
| 306 | numpy.polynomial.laguerre.lagfromroots |
| 307 | numpy.polynomial.hermite.hermfromroots |
| 308 | numpy.polynomial.hermite_e.hermefromroots |
| 309 | |
| 310 | Examples |
| 311 | -------- |
| 312 | >>> import numpy.polynomial.legendre as L |
| 313 | >>> L.legfromroots((-1,0,1)) # x^3 - x relative to the standard basis |
| 314 | array([ 0. , -0.4, 0. , 0.4]) |
| 315 | >>> j = complex(0,1) |
| 316 | >>> L.legfromroots((-j,j)) # x^2 + 1 relative to the standard basis |
| 317 | array([ 1.33333333+0.j, 0.00000000+0.j, 0.66666667+0.j]) # may vary |
| 318 | |
| 319 | """ |
| 320 | return pu._fromroots(legline, legmul, roots) |
| 321 | |
| 322 | |
| 323 | def legadd(c1, c2): |
nothing calls this directly
no test coverage detected
searching dependent graphs…