# polyval¶

numeric.fitting.polyval(p, x)

Evaluate a polynomial at specific values.

If p is of length N, this function returns the value:

p*x**(N-1) + p*x**(N-2) + … + p[N-2]*x + p[N-1]

If x is a sequence, then p(x) is returned for each element of x. If x is another polynomial then the composite polynomial p(x(t)) is returned.

Parameters
• p – (array_like) 1D array of polynomial coefficients (including coefficients equal to zero) from highest degree to the constant term.

• x – (array_like) A number, an array of numbers, or an instance of poly1d, at which to evaluate p.

Returns

Polynomial value

Examples:

from mipylib.numeric import fitting

x = linspace(0, 4*pi, 10)
y = sin(x)

#Plot data points
plot(x, y, 'ro', fill=False, size=1)

#Use polyfit to fit a 7th-degree polynomial to the points
r = fitting.polyfit(x, y, 7)

#Plot fitting line
xx = linspace(0, 4*pi, 100)
p = r
yy = fitting.polyval(p, xx)
plot(xx, yy, '-b')
title('Polynomial fitting example')
{"ft_lang_label":"__label__en","ft_lang_prob":0.6226938,"math_prob":0.99905545,"size":972,"snap":"2019-51-2020-05","text_gpt3_token_len":295,"char_repetition_ratio":0.12809917,"word_repetition_ratio":0.0,"special_character_ratio":0.30761316,"punctuation_ratio":0.14761905,"nsfw_num_words":1,"has_unicode_error":false,"math_prob_llama3":0.9999298,"pos_list":[0,1,2],"im_url_duplicate_count":[null,6,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-01-23T03:41:16Z\",\"WARC-Record-ID\":\"<urn:uuid:4a5326b1-0f6e-43b1-ba5a-8aa9579245ec>\",\"Content-Length\":\"11946\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:d9c3c278-585c-4192-8f23-a71de67b208d>\",\"WARC-Concurrent-To\":\"<urn:uuid:188b1eab-7925-4ee9-9ca1-981d8121b780>\",\"WARC-IP-Address\":\"148.66.137.35\",\"WARC-Target-URI\":\"http://meteothink.org/docs/meteoinfolab/numeric/fitting/polyval.html\",\"WARC-Payload-Digest\":\"sha1:TEQLWFI7UJNEI4X2NZKSHMGEIRQYTZJJ\",\"WARC-Block-Digest\":\"sha1:NDAWZNPLJFUZBKJ2BOPIBES76UUQTI62\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-05/CC-MAIN-2020-05_segments_1579250608062.57_warc_CC-MAIN-20200123011418-20200123040418-00516.warc.gz\"}"}