File:Quadratic equation coefficients with standard ranges.png

From testwiki
Jump to navigation Jump to search
    Original file (1,276 × 877 pixels, file size: 124 KB, MIME type: image/png)

    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

    Description
    English: Plots of quadratic function y = ax2 + bx + c, varying each coefficient separately while the other coefficients are fixed (at values a = 1, b = 0, c = 0). Improvement over the previous figure (File:Quadratic equation coefficients.png) as it uses harmonized ranges.
    Date
    Source Own work
    Author Raphaaal

    Source Code

    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib.lines import Line2D
    plt.rcParams['font.family'] = 'serif'
    plt.rcParams['font.serif'] = ['Computer Modern Roman']
    plt.rcParams['mathtext.fontset'] = 'cm'
    
    # Setup
    dpi = 300
    width_px, height_px = 1276, 877
    fig, axs = plt.subplots(1, 3, figsize=(width_px/dpi, height_px/dpi), dpi=dpi)
    x_range = np.linspace(-2, 2, 1600)
    param_vals = [1/3, 3/2, -1/2, -4/3, 0]
    colors = ["#387FC7", "#F5C443", "#40904E", "#AD3049", "#000000"]
    
    # Plot quadratic functions with varying parameters
    params = [
        ('c', lambda x, p: x**2 + p),      # y = x^2 + c
        ('b', lambda x, p: x**2 + p * x),  # y = x^2 + bx
        ('a', lambda x, p: p * x**2)       # y = ax^2
    ]
    for i, (label, func) in enumerate(params):
        for val, color in zip(param_vals, colors):
            axs[i].plot(x_range, func(x_range, val), color=color, lw=1.5, zorder=i+1)
        if label == 'b':
            # Plot the vertices parabolic curve when varying `b`
            axs[i].plot(x_range, -x_range**2, color='grey', lw=1.5, linestyle=':', zorder=0)
        axs[i].set_xlabel(rf"$\boldsymbol{{{label}}}$", fontsize=14)
    
    # Format axes
    for ax in axs:
        ax.set_xlim(-2, 2)
        ax.set_xticks(np.arange(-2, 3))
        ax.set_ylim(-2, 2)
        ax.set_yticks(np.arange(-2, 3))
        ax.axhline(0, color='grey', linewidth=0.5, zorder=0)
        ax.axvline(0, color='grey', linewidth=0.5, zorder=0)
        for spine in ax.spines.values():
            spine.set_edgecolor('grey')
            spine.set_linewidth(0.5)
        ax.tick_params(axis='both', colors='grey', labelsize=4, width=0.5)
    
    # Legend
    labels = [
        r"$-\frac{4}{3}$,", 
        r"$-\frac{1}{2}$, ",
        r"$0$,", 
        r"$+\frac{1}{3}$,", 
        r"$+\frac{3}{2}$"
    ]
    annot_colors = [colors[3], colors[2], colors[4], colors[0], colors[1]]
    handles = [Line2D([], [], color=c, lw=0) for c in colors]
    leg = fig.legend(
        handles, labels,
        loc=("upper center"), bbox_to_anchor=(0.5, 0.99),
        frameon=False, ncol=len(labels), handlelength=0.0, handletextpad=0.1,
        columnspacing=0.2, fontsize=18,
     )
    for txt, c in zip(leg.get_texts(), annot_colors):
        txt.set_color(c)
    
    # Show
    plt.tight_layout(rect=(0, 0, 1, 0.80), w_pad=0.5)
    plt.show()
    fig.savefig("Quadratic_equation_coefficients_standard_ranges.png", dpi=dpi)
    

    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.

    Captions

    Plots of quadratic function y = ax2 + bx + c, varying each coefficient separately while the other coefficients are fixed (at values a = 1, b = 0, c = 0)

    Items portrayed in this file

    depicts

    10 January 2026

    image/png

    126,891 byte

    877 pixel

    1,276 pixel

    cfc0e7b4d9ee4460bea9eeab4b983480cb3709f6

    File history

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

    Date/TimeThumbnailDimensionsUserComment
    current00:15, 11 January 2026Thumbnail for version as of 00:15, 11 January 20261,276 × 877 (124 KB)wikimediacommons>RaphaaalUse LaTex font and plot vertices curve when varying `b`

    There are no pages that use this file.