File:Gelfand's formula for a 3x3 matrix.svg

From testwiki
Jump to navigation Jump to search
    Original file (SVG file, nominally 614 × 461 pixels, file size: 24 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: Gelfand's formula for a 3x3 matrix

    Python

    import numpy as np
    import matplotlib.pyplot as plt
    
    A = np.array([[9, -1, 2],
                  [-2, 8, 4],
                  [1, 1, 8]], dtype=np.float64)
    
    k_values = np.arange(1, 200)
    k_values = k_values.astype(int)
    norm_1_inf_values = []
    norm_F_values = []
    norm_2_values = []
    
    for k in k_values:
        A_k = np.linalg.matrix_power(A, k)
        norm_1_inf = np.linalg.norm(A_k, ord=1)**(1/k)
        norm_F = np.linalg.norm(A_k, ord='fro')**(1/k)
        norm_2 = np.linalg.norm(A_k, ord=2)**(1/k)
        
        norm_1_inf_values.append(norm_1_inf)
        norm_F_values.append(norm_F)
        norm_2_values.append(norm_2)
    
    norm_1_inf_values = np.array(norm_1_inf_values) - 10
    norm_F_values = np.array(norm_F_values) - 10
    norm_2_values = np.array(norm_2_values) - 10
    
    plt.plot(k_values, norm_1_inf_values, label=r'$\| \cdot \|_1 = \| \cdot \|_\infty$')
    plt.plot(k_values, norm_F_values, label=r'$\| \cdot \|_F$')
    plt.plot(k_values, norm_2_values, label=r'$\| \cdot \|_2$')
    # set log-log
    plt.xscale('log')
    plt.yscale('log')
    # remove x-ticks
    # plt.xticks([])
    plt.xlabel(r'$k$')
    plt.ylabel(r'$\|A^k\|^{\frac{1}{k}} - \|A^\infty\|^{\frac{1}{\infty}}$')
    
    plt.legend()
    plt.savefig("Gelfand's formula.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 January 2025

    24,283 byte

    image/svg+xml

    1a32675e3c85955fa173f96f2054a8ecee49d1a7

    File history

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

    Date/TimeThumbnailDimensionsUserComment
    current19:17, 26 January 2025Thumbnail for version as of 19:17, 26 January 2025614 × 461 (24 KB)wikimediacommons>Cosmia NebulaUploaded while editing "Spectral radius" on en.wikipedia.org

    There are no pages that use this file.