[Python] polynomial evaluation producing non-differentiable behavior in Python

Discussão em 'Python' iniciado por Stack, Fevereiro 17, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to evaluate a polynomial of degree 61. However, around the point sqrt(2) I get some weird behavior. The graph of the polynomial becomes erratic. What could be the reason for this. The following python code is used

    I = np.sqrt(2)+1j*np.linspace(0,1e-6,1000, dtype = np.clongdouble)
    Y = np.abs(np.polynomial.polynomial.polyval(I, coefficients_rev))
    plt.plot(np.linspace(0,1,1000),Y)
    plt.show()


    with coefficients given by

    coefficients = np.array([ 1.00000000e+00+0.j, 0.00000000e+00+0.j, -3.04750157e+01+0.j,
    0.00000000e+00+0.j, 4.49106800e+02+0.j, 0.00000000e+00+0.j,
    -4.26240239e+03+0.j, 0.00000000e+00+0.j, 2.92734180e+04+0.j,
    0.00000000e+00+0.j, -1.54973591e+05+0.j, 0.00000000e+00+0.j,
    6.57829830e+05+0.j, 0.00000000e+00+0.j, -2.29933795e+06+0.j,
    0.00000000e+00+0.j, 6.74451933e+06+0.j, 0.00000000e+00+0.j,
    -1.68346568e+07+0.j, 0.00000000e+00+0.j, 3.61319542e+07+0.j,
    0.00000000e+00+0.j, -6.72090548e+07+0.j, 0.00000000e+00+0.j,
    1.08986264e+08+0.j, 0.00000000e+00+0.j, -1.54736506e+08+0.j,
    0.00000000e+00+0.j, 1.92921639e+08+0.j, 0.00000000e+00+0.j,
    -2.11600531e+08+0.j, 0.00000000e+00+0.j, 2.04319983e+08+0.j,
    0.00000000e+00+0.j, -1.73627642e+08+0.j, 0.00000000e+00+0.j,
    1.29668219e+08+0.j, 0.00000000e+00+0.j, -8.48892421e+07+0.j,
    0.00000000e+00+0.j, 4.85309319e+07+0.j, 0.00000000e+00+0.j,
    -2.41002152e+07+0.j, 0.00000000e+00+0.j, 1.03215590e+07+0.j,
    0.00000000e+00+0.j, -3.77608656e+06+0.j, 0.00000000e+00+0.j,
    1.16509284e+06+0.j, 0.00000000e+00+0.j, -2.97955777e+05+0.j,
    0.00000000e+00+0.j, 6.16343028e+04+0.j, 0.00000000e+00+0.j,
    -9.94806340e+03+0.j, 0.00000000e+00+0.j, 1.18267487e+03+0.j,
    0.00000000e+00+0.j, -9.31129650e+01+0.j, 0.00000000e+00+0.j,
    3.72597504e+00+0.j, 0.00000000e+00+0.j], dtype=np.clongdouble)

    coefficients_rev = coefficients[::-1]


    How can this plot be explained: [​IMG]

    I am interested in computing non-classical Chebyshev polynomials minimizing ||z^n+lower.order|| for large n over compact subsets of the complex plane using the remez algorithm generalized by P.T.P Tang. I get a good enough looking plot, however, I also get artifacts at certain points. In the example below the left most point where the graph becomes erratic corresponds to approaching sqrt(2) from imaginary numbers.

    [​IMG]

    I am simply interested in understanding this behavior from a numerical standpoint and if something can be done to remedy this.

    Continue reading...

Compartilhe esta Página