File:Quadratic basis.svg

Summary

Description
English: Basis for all quadratic functions, plotted in the interval [0, 3].
Date
Source Own work
Author Åshild Telle
SVG development
InfoField

Licensing

I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International 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.
Category:CC-BY-SA-4.0#Quadratic%20basis.svg
Category:Self-published work

Code

import numpy as np
import matplotlib.pyplot as plt

"""
    Plots the function
        f(x) = x**n
    over a given interval.

    Arguments:
        x : Numpy array
        n : Integer value
"""
def plot_basis(x, n):
    y = np.power(x, n)
    plt.plot(x, y)

x = np.linspace(0, 3, 100)

plot_basis(x, 0)
plot_basis(x, 1)
plot_basis(x, 2)
plt.legend(["$1$", "$x$", "$x^2$"])

plt.xlim([min(x), max(x)])
plt.savefig("quadratic_basis.svg", format="svg")
plt.show()
Category:Basis functions Category:Polynomial functions
Category:Basis functions Category:CC-BY-SA-4.0 Category:Polynomial functions Category:Self-published work Category:Valid SVG created with Matplotlib