Saltar al contenido principal
LibreTexts Español

44.3: Revisión de Python Numpy Package

  • Page ID
    115578
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    from urllib.request import urlretrieve
    urlretrieve('https://raw.githubusercontent.com/colbrydi/jupytercheck/master/answercheck.py', 
                'answercheck.py');
    Hacer esto

    Vea el siguiente video sobre el paquete Python Numpy.

    Enlace directo al video de Youtube.

    from IPython.display import YouTubeVideo
    YouTubeVideo("_hbWtNgstlI",width=640,height=320, cc_load_policy=True)

    La biblioteca Python Numpy tiene un objeto de matriz que se puede inicializar de la siguiente manera:

    import numpy as np
    A = np.matrix([[1,1], [20,25]])
    b = np.matrix([[30],[690]])
    print("A="+str(A))
    print("b="+str(b))
    A=[[ 1  1]
     [20 25]]
    b=[[ 30]
     [690]]
    

    Python puede resolver ecuaciones en el\(Ax=b\) formato con la biblioteca numpy.linalg. Por ejemplo:

    import numpy as np
    
    x = np.linalg.solve(A, b)
    print("x="+str(x))
    x=[[12.]
     [18.]]
    

    La biblioteca numpy.linalg es solo un subconjunto de la biblioteca scipy.linalg.

    import scipy.linalg as la
    
    x = la.solve(A, b)
    print("X="+str(x))
    X=[[12.]
     [18.]]
    
    Hacer esto

    Convierta el siguiente sistema de ecuaciones lineales en matrices numpy y resuelva cantar un solucionador de álgebra lineal Python (Almacene las soluciones en un vector llamado x).

    \(18x + 21y = 22672x - 3y = 644\)

    ##Put your answer to the above question here.
    from answercheck import checkanswer
    
    checkanswer.vector(x,'756ca9fa3951fad0e623b2a8315d5fd7');

    This page titled 44.3: Revisión de Python Numpy Package is shared under a CC BY-NC 4.0 license and was authored, remixed, and/or curated by Dirk Colbry via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.