File:Bregman exp.svg

From testwiki
Jump to navigation Jump to search
    Original file (SVG file, nominally 768 × 576 pixels, file size: 36 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

    Description
    English:

    Matplotlib code

    import numpy as np
    import matplotlib.pyplot as plt
    
    # F = exp
    def F(x):
        return np.exp(x)
    
    def dF(x):
        return np.exp(x)
    
    x = np.linspace(-2, 2, 400)
    
    # two points
    q = -0.5
    p = 1.0
    
    Fq = F(q)
    Fp = F(p)
    dFq = dF(q)
    dFp = dF(p)
    
    tangent_q = Fq + dFq * (x - q)
    tangent_p = Fp + dFp * (x - p)
    
    plt.figure(figsize=(8, 6))
    plt.plot(x, F(x), linewidth=2, label="F(x)=exp(x)")
    plt.plot(x, tangent_q, "--", linewidth=1.2, label="Tangent at q")
    plt.plot(x, tangent_p, ":", linewidth=1.2, label="Tangent at p")
    
    # mark points
    plt.scatter([q], [Fq], marker="o")
    plt.scatter([p], [Fp], marker="s")
    
    # vertical gaps showing asymmetry
    plt.vlines(p, tangent_q[np.searchsorted(x, p)], Fp, linestyles="-", linewidth=2)
    plt.vlines(q, tangent_p[np.searchsorted(x, q)], Fq, linestyles="-", linewidth=2)
    
    plt.title("Bregman distance of F(x)=exp(x)")
    plt.xlabel("x")
    plt.ylabel("F(x)")
    plt.grid()
    plt.legend()
    plt.tight_layout()
    plt.savefig("bregman_exp.svg")
    plt.show()
    

    Date
    Source Own work
    Author Cosmia Nebula

    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

    Add a one-line explanation of what this file represents

    Items portrayed in this file

    depicts

    26 November 2025

    image/svg+xml

    37,058 byte

    bb7031854200c26aa06fd5d32084dec54d72e84e

    File history

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

    Date/TimeThumbnailDimensionsUserComment
    current05:14, 27 November 2025Thumbnail for version as of 05:14, 27 November 2025768 × 576 (36 KB)wikimediacommons>Cosmia NebulaUploaded while editing "Bregman divergence" on en.wikipedia.org

    There are no pages that use this file.