File:Lagrange polynomial.svg

From testwiki
Jump to navigation Jump to search
    Original file (SVG file, nominally 743 × 503 pixels, file size: 85 KB)

    This file is from Wikimedia Commons and may be used by other projects. The description on its file description page there is shown below.

    Summary

     This W3C-unspecified diagram was created with Mathematica.
    Description
    English: This image shows, for four points ((−9, 5), (−4, 2), (−1, −2), (7, 9)), the (cubic) interpolation polynomial L(x) (dashed, black), which is the sum of the scaled basis polynomials y1ℓ1(x), y2ℓ2(x), y3ℓ3(x) and y4ℓ4(x) (colors). The interpolation polynomial passes through all four control points, and each scaled basis polynomial passes through its respective control point and is 0 where x corresponds to the other three control points.
    Date
    Source Self-made, based on Image:Lagrangepolys.png
    Author User:Glosser.ca
    Other versions Based on Image:Lagrangepolys.png.

    Mathematica Code

    colors = ColorData[97] /@ Range[4];
    pts = {{\[Minus]9, 5}, {\[Minus]4, 2}, {\[Minus]1, \[Minus]2}, {7, 9}};
    {xs, ys} = Transpose[pts];
    
    Basis[pts_, x_] := Times @@ (x - DeleteCases[pts, #])/Times @@ (# - DeleteCases[pts, #]) & /@ pts
    
    Plot[
     {
      Evaluate[ys*Basis[xs, x]],
      Total[ys*Basis[xs, x]]
     }, {x, -9, 7},
     PlotStyle -> {Automatic, Automatic, Automatic, Automatic, Directive[Black, Dashed]},
     Frame -> True,
     Axes -> False,
     ImageSize -> Large,
     GridLines -> Automatic,
     GridLinesStyle -> Directive[LightGray, Dashed],
     PlotStyle -> Thick,
     Epilog -> Table[{PointSize[0.02], ColorData[97][i], Point[pts[[i]]]}, {i,4}],
     PlotLegends -> Placed[
      LineLegend[{
       Subscript[\[ScriptL], 1][x], 
       Subscript[\[ScriptL], 2][x],
       Subscript[\[ScriptL], 3][x], 
       Subscript[\[ScriptL], 4][x],
       L[x]
      }, LegendLayout -> {"Row", 1}],
      Top
     ],
     FrameStyle -> Black
    ]
    

    Licensing

    I, the copyright holder of this work, hereby publish it under the following licenses:
    GNU head Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled GNU Free Documentation License.
    w:en:Creative Commons
    attribution share alike
    This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license.
    You are free:
    • to share – to copy, distribute and transmit the work
    • to remix – to adapt the work
    Under the following conditions:
    • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
    • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
    This licensing tag was added to this file as part of the GFDL licensing update.
    You may select the license of your choice.

    Captions

    Add a one-line explanation of what this file represents

    Items portrayed in this file

    depicts

    26 December 2015

    87,026 byte

    image/svg+xml

    63f4f5ef917a641132a539413082c987d75fe2fa

    File history

    Click on a date/time to view the file as it appeared at that time.

    Date/TimeThumbnailDimensionsUserComment
    current19:29, 23 April 2016Thumbnail for version as of 19:29, 23 April 2016743 × 503 (85 KB)wikimediacommons>RayhemSwapped axis for frame; added legend.

    There are no pages that use this file.