<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>scipy.interpolate.pchip.from_derivatives — SciPy v1.1.0.dev0+4e64658 Reference Guide</title> <link rel="stylesheet" type="text/css" href="../_static/css/spc-bootstrap.css"> <link rel="stylesheet" type="text/css" href="../_static/css/spc-extend.css"> <link rel="stylesheet" href="../_static/scipy.css" type="text/css" > <link rel="stylesheet" href="../_static/pygments.css" type="text/css" > <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', VERSION: '1.1.0.dev0+4e64658', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: false }; </script> <script type="text/javascript" src="../_static/jquery.js"></script> <script type="text/javascript" src="../_static/underscore.js"></script> <script type="text/javascript" src="../_static/doctools.js"></script> <script type="text/javascript" src="../_static/scipy-mathjax/MathJax.js?config=scipy-mathjax"></script> <script type="text/javascript" src="../_static/js/copybutton.js"></script> <link rel="index" title="Index" href="../genindex.html" > <link rel="search" title="Search" href="../search.html" > <link rel="top" title="SciPy v1.1.0.dev0+4e64658 Reference Guide" href="../index.html" > </head> <body> <div class="container"> <div class="header"> </div> </div> <div class="container"> <div class="main"> <div class="row-fluid"> <div class="span12"> <div class="spc-navbar"> <ul class="nav nav-pills pull-left"> <li class="active"><a href="../index.html">SciPy v1.1.0.dev0+4e64658 Reference Guide</a></li> </ul> <ul class="nav nav-pills pull-right"> <li class="active"> <a href="../genindex.html" title="General Index" accesskey="I">index</a> </li> <li class="active"> <a href="../py-modindex.html" title="Python Module Index" >modules</a> </li> </ul> </div> </div> </div> <div class="row-fluid"> <div class="spc-rightsidebar span3"> <div class="sphinxsidebarwrapper"> <p class="logo"><a href="../index.html"> <img class="logo" src="../_static/scipyshiny_small.png" alt="Logo"> </a></p> </div> </div> <div class="span9"> <div class="bodywrapper"> <div class="body" id="spc-section-body"> <div class="section" id="scipy-interpolate-pchip-from-derivatives"> <h1>scipy.interpolate.pchip.from_derivatives<a class="headerlink" href="#scipy-interpolate-pchip-from-derivatives" title="Permalink to this headline">¶</a></h1> <dl class="method"> <dt id="scipy.interpolate.pchip.from_derivatives"> <code class="descclassname">pchip.</code><code class="descname">from_derivatives</code><span class="sig-paren">(</span><em>xi</em>, <em>yi</em>, <em>orders=None</em>, <em>extrapolate=None</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/scipy/scipy/blob/4e64658/scipy/interpolate/interpolate.py#L1602-L1718"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#scipy.interpolate.pchip.from_derivatives" title="Permalink to this definition">¶</a></dt> <dd><p>Construct a piecewise polynomial in the Bernstein basis, compatible with the specified values and derivatives at breakpoints.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>xi</strong> : array_like</p> <blockquote> <div><p>sorted 1D array of x-coordinates</p> </div></blockquote> <p><strong>yi</strong> : array_like or list of array_likes</p> <blockquote> <div><p><code class="docutils literal"><span class="pre">yi[i][j]</span></code> is the <code class="docutils literal"><span class="pre">j</span></code>-th derivative known at <code class="docutils literal"><span class="pre">xi[i]</span></code></p> </div></blockquote> <p><strong>orders</strong> : None or int or array_like of ints. Default: None.</p> <blockquote> <div><p>Specifies the degree of local polynomials. If not None, some derivatives are ignored.</p> </div></blockquote> <p><strong>extrapolate</strong> : bool or ‘periodic’, optional</p> <blockquote class="last"> <div><p>If bool, determines whether to extrapolate to out-of-bounds points based on first and last intervals, or to return NaNs. If ‘periodic’, periodic extrapolation is used. Default is True.</p> </div></blockquote> </td> </tr> </tbody> </table> <p class="rubric">Notes</p> <p>If <code class="docutils literal"><span class="pre">k</span></code> derivatives are specified at a breakpoint <code class="docutils literal"><span class="pre">x</span></code>, the constructed polynomial is exactly <code class="docutils literal"><span class="pre">k</span></code> times continuously differentiable at <code class="docutils literal"><span class="pre">x</span></code>, unless the <code class="docutils literal"><span class="pre">order</span></code> is provided explicitly. In the latter case, the smoothness of the polynomial at the breakpoint is controlled by the <code class="docutils literal"><span class="pre">order</span></code>.</p> <p>Deduces the number of derivatives to match at each end from <code class="docutils literal"><span class="pre">order</span></code> and the number of derivatives available. If possible it uses the same number of derivatives from each end; if the number is odd it tries to take the extra one from y2. In any case if not enough derivatives are available at one end or another it draws enough to make up the total from the other end.</p> <p>If the order is too high and not enough derivatives are available, an exception is raised.</p> <p class="rubric">Examples</p> <div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">scipy.interpolate</span> <span class="k">import</span> <span class="n">BPoly</span> <span class="gp">>>> </span><span class="n">BPoly</span><span class="o">.</span><span class="n">from_derivatives</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">],</span> <span class="p">[[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">],</span> <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">]])</span> </pre></div> </div> <p>Creates a polynomial <em class="xref py py-obj">f(x)</em> of degree 3, defined on <em class="xref py py-obj">[0, 1]</em> such that <em class="xref py py-obj">f(0) = 1, df/dx(0) = 2, f(1) = 3, df/dx(1) = 4</em></p> <div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">BPoly</span><span class="o">.</span><span class="n">from_derivatives</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">],</span> <span class="p">[[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">],</span> <span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="p">[</span><span class="mi">2</span><span class="p">]])</span> </pre></div> </div> <p>Creates a piecewise polynomial <em class="xref py py-obj">f(x)</em>, such that <em class="xref py py-obj">f(0) = f(1) = 0</em>, <em class="xref py py-obj">f(2) = 2</em>, and <em class="xref py py-obj">df/dx(0) = 1</em>. Based on the number of derivatives provided, the order of the local polynomials is 2 on <em class="xref py py-obj">[0, 1]</em> and 1 on <em class="xref py py-obj">[1, 2]</em>. Notice that no restriction is imposed on the derivatives at <em class="xref py py-obj">x = 1</em> and <em class="xref py py-obj">x = 2</em>.</p> <p>Indeed, the explicit form of the polynomial is:</p> <div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">f</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="o">=</span> <span class="o">|</span> <span class="n">x</span> <span class="o">*</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">x</span><span class="p">),</span> <span class="mi">0</span> <span class="o"><=</span> <span class="n">x</span> <span class="o"><</span> <span class="mi">1</span> <span class="o">|</span> <span class="mi">2</span> <span class="o">*</span> <span class="p">(</span><span class="n">x</span> <span class="o">-</span> <span class="mi">1</span><span class="p">),</span> <span class="mi">1</span> <span class="o"><=</span> <span class="n">x</span> <span class="o"><=</span> <span class="mi">2</span> </pre></div> </div> <p>So that f’(1-0) = -1 and f’(1+0) = 2</p> </dd></dl> </div> </div> </div> </div> </div> </div> </div> <div class="container container-navbar-bottom"> <div class="spc-navbar"> </div> </div> <div class="container"> <div class="footer"> <div class="row-fluid"> <ul class="inline pull-left"> <li> © Copyright 2008-2016, The Scipy community. </li> <li> Last updated on Sep 21, 2017. </li> <li> Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.6.3. </li> </ul> </div> </div> </div> </body> </html>