{"id":115539,"date":"2020-07-17T19:27:24","date_gmt":"2020-07-17T19:27:24","guid":{"rendered":"https:\/\/blog.finxter.com\/?p=11000"},"modified":"2020-07-17T19:27:24","modified_gmt":"2020-07-17T19:27:24","slug":"numpy-polymulx","status":"publish","type":"post","link":"https:\/\/sickgaming.net\/blog\/2020\/07\/17\/numpy-polymulx\/","title":{"rendered":"NumPy polymulx()"},"content":{"rendered":"<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">numpy.polynomial.polynomial.polymulx(c)<\/pre>\n<p class=\"has-pale-cyan-blue-background-color has-background\">The <code><a href=\"https:\/\/numpy.org\/doc\/stable\/reference\/generated\/numpy.polynomial.polynomial.polymulx.html#numpy.polynomial.polynomial.polymulx\" target=\"_blank\" rel=\"noreferrer noopener\" title=\"https:\/\/numpy.org\/doc\/stable\/reference\/generated\/numpy.polynomial.polynomial.polymulx.html#numpy.polynomial.polynomial.polymulx\">numpy.polymulx<\/a><\/code> function multiplies the polynomial <code>c<\/code> with a value <code>x<\/code> which is the independent variable.<\/p>\n<figure class=\"wp-block-table is-style-stripes\">\n<table>\n<thead>\n<tr>\n<th>Arguments<\/th>\n<th>Type<\/th>\n<th>Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><strong>c<\/strong><\/td>\n<td>array_like or poly1d object<\/td>\n<td>The input polynomials to be multiplied<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<p>The following table shows the return value of the function:<\/p>\n<figure class=\"wp-block-table is-style-stripes\">\n<table>\n<thead>\n<tr>\n<th><\/th>\n<th>Type<\/th>\n<th>Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><strong><strong>Return Value<\/strong><\/strong><\/td>\n<td>ndarray or poly1d object<\/td>\n<td>The polynomial resulting from the multiplication of the inputs. If either inputs is a poly1d object, then the output is also a poly1d object. Otherwise, it is a 1D array of polynomial coefficients from highest to lowest degree.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<p>Let&#8217;s dive into some examples to show how the function is used in practice:<\/p>\n<h3>Examples<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\nimport numpy as np\nimport numpy.polynomial.polynomial as poly print(poly.polymulx([0]) == [0])\nprint(poly.polymulx([1]) == [0, 1])\nfor i in range(1, 5): ser = [0]*i + [1] tgt = [0]*(i + 1) + [1] print(poly.polymulx(ser) == tgt) '''\n[ True]\n[ True True]\n[ True True True]\n[ True True True True]\n[ True True True True True]\n[ True True True True True True] '''<\/pre>\n<p>This function is inspired from <a href=\"https:\/\/github.com\/Frank-qlu\/recruit\" target=\"_blank\" rel=\"noreferrer noopener\" title=\"https:\/\/github.com\/Frank-qlu\/recruit\">this <\/a>Github repository.<\/p>\n<p>Any master coder has a &#8220;hands-on&#8221; mentality with a bias towards action. Try it yourself&#8212;play with the function in the following interactive code shell:<\/p>\n<p> <iframe loading=\"lazy\" height=\"400px\" width=\"100%\" src=\"https:\/\/repl.it\/@finxter\/polyx?lite=true\" scrolling=\"no\" frameborder=\"no\" allowtransparency=\"true\" allowfullscreen=\"true\" sandbox=\"allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-modals\"><\/iframe> <\/p>\n<p><em><strong>Exercise<\/strong>: Change the parameters of your polynomials and print them without the comparisons. Do you understand where they come from?<\/em><\/p>\n<p><em><strong>Master NumPy&#8212;and become a data science pro:<\/strong><\/em><\/p>\n<figure class=\"wp-block-image size-large is-resized\"><a href=\"https:\/\/blog.finxter.com\/coffee-break-numpy\/\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/blog.finxter.com\/wp-content\/uploads\/2019\/04\/Cover_Coffee_Break_NumPy_v2-1-683x1024.png\" alt=\"Coffee Break NumPy\" class=\"wp-image-2860\" width=\"342\" height=\"512\" srcset=\"https:\/\/blog.finxter.com\/wp-content\/uploads\/2019\/04\/Cover_Coffee_Break_NumPy_v2-1.png 683w, https:\/\/blog.finxter.com\/wp-content\/uploads\/2019\/04\/Cover_Coffee_Break_NumPy_v2-1-200x300.png 200w, https:\/\/blog.finxter.com\/wp-content\/uploads\/2019\/04\/Cover_Coffee_Break_NumPy_v2-1-768x1152.png 768w, https:\/\/blog.finxter.com\/wp-content\/uploads\/2019\/04\/Cover_Coffee_Break_NumPy_v2-1-100x150.png 100w, https:\/\/blog.finxter.com\/wp-content\/uploads\/2019\/04\/Cover_Coffee_Break_NumPy_v2-1-670x1005.png 670w\" sizes=\"auto, (max-width: 342px) 100vw, 342px\" \/><\/a><\/figure>\n<h2>Related Video<\/h2>\n<figure class=\"wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\">\n<div class=\"wp-block-embed__wrapper\">\n<div class=\"ast-oembed-container\"><iframe loading=\"lazy\" title=\"NumPy Tutorial - Everything You Need to Know to Get Started\" width=\"1400\" height=\"788\" src=\"https:\/\/www.youtube.com\/embed\/s55BEAJRTOk?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe><\/div>\n<\/div>\n<\/figure>\n","protected":false},"excerpt":{"rendered":"<p>numpy.polynomial.polynomial.polymulx(c) The numpy.polymulx function multiplies the polynomial c with a value x which is the independent variable. Arguments Type Description c array_like or poly1d object The input polynomials to be multiplied The following table shows the return value of the function: Type Description Return Value ndarray or poly1d object The polynomial resulting from the multiplication [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[857],"tags":[73,468,528],"class_list":["post-115539","post","type-post","status-publish","format-standard","hentry","category-python-tut","tag-programming","tag-python","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts\/115539","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/comments?post=115539"}],"version-history":[{"count":0,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts\/115539\/revisions"}],"wp:attachment":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/media?parent=115539"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/categories?post=115539"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/tags?post=115539"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}