Académique Documents
Professionnel Documents
Culture Documents
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsfonts, amsmath, amsthm, amssymb}
\usepackage{listings}
\usepackage{xcolor}
\newcounter{countCode}
\lstnewenvironment{code} [1][caption=Ponme caption, label=default]{%
\renewcommand*{\lstlistingname}{Listado}
\setcounter{lstlisting}{\value{countCode}}
\lstset{ %
language=java,
basicstyle=\ttfamily\footnotesize, % the size of the fonts that are used for the
code
numbers=left, % where to put the line-numbers
numberstyle=\sc, % the size of the fonts that are used for the line-numbers
stepnumber=1, % the step between two line-numbers.
numbersep=5pt, % how far the line-numbers are from the code
numberstyle=\color{red!50!blue},
backgroundcolor=\color{lightgray!20},
rulecolor=\color{blue},
keywordstyle=\color{red}\bfseries,
showspaces=false, % show spaces adding particular underscores
showstringspaces=false, % underline spaces within strings
showtabs=false, % show tabs within strings adding particular underscores
frame=single, % adds a frame around the code
framexleftmargin=0mm,
numberblanklines=false,
xleftmargin=5pt,
breaklines=true,
breakatwhitespace=true,
breakautoindent=true,
captionpos=t,
texcl=true,
tabsize=2, % sets default tabsize to 3 spaces
extendedchars=true,
inputencoding=utf8,
escapechar=\%,
morekeywords={print, println, size, background, strokeWeight, fill, line, rect,
ellipse, triangle, arc, save, PI, HALF_PI, QUARTER_PI, TAU, TWO_PI, width, height,},
emph=[1]{print,println,}, emphstyle=[1]{\color{blue}}, % Mis palabras clave.
emph=[2]{width,height,}, emphstyle=[2]{\bf\color{violet}}, % Mis palabras clave.
emph=[3]{PI, HALF_PI, QUARTER_PI, TAU, TWO_PI},
emphstyle=[3]\color{orange!50!violet}, % Mis palabras clave.
emph=[4]{line, rect, ellipse, triangle, arc,}, emphstyle=[4]\color{green!70!black},
% Mis palabras clave.
%emph=[5]{size, background, strokeWeight, fill,}, emphstyle=[5]{\tt \color{red!
30!blue}}, % Mis palabras clave.
%emph={[2]sqrt,baset}, emphstyle={[2]\color{blue}}, % f(sqrt(2)), sqrt a nivel 2
se pondrá azul
#1}}{\addtocounter{countCode}{1}}
\usepackage{graphicx}
\begin{document}
\begin{titlepage}
\begin{center}
\vspace*{6\baselineskip}
{\large{ESCUELA DE INGENIEROS MILITARES}}\\[0.1cm]{\large{MODALIDAD A
DISTANCIA}}
\vspace*{3\baselineskip}
\begin{figure}[h!]
\centering
\includegraphics[scale=0.3]{logo.png}
\label{fig:logo}
\end{figure}
\vspace*{2\baselineskip}\\
INFORMATICA APLICADA\\
LABORATORIO DE PYTHON
\vspace*{5\baselineskip}\\
RAFAEL ANTONIO CARDONA ESPINOSA\\
FABIAN LENADRO DUQUE
\vfill
\today
\end{center}
\end{titlepage}
\begin{equation}
\textbf{A} = \left[
\begin{array}{cccc}
a_{11} & a_{12} & \cdots & a_{1m} \\
a_{21} & a_{22} & \cdots & a_{2m} \\
\vdots & \vdots & \ddots & \vdots \\
a_{n1} & a_{n2} & \cdots & a_{nm} \\
\end{array}
\right]
\end{equation}
\begin{figure}[h!]
\centering
\includegraphics[scale=0.5]{conm.png}
\caption{Esquemas de productos matrices}
\label{fig:conm}
\end{figure}
\section{MULTIPLICACION DE MATRICES}
Las operaciones de matrices a la de multiplicar se realizan:
$$
\begin{bmatrix}
A1 & A2 & A3\\
A4 & A5 & A6\\
A7 & A8 & A9\\
\end{bmatrix}
*
\begin{bmatrix}
B1 & B2 & B3 \\
B4 & B5 & B6 \\
B7 & B8 & B9 \\
\end{bmatrix}
=
\begin{bmatrix}
A1B1 & A2B2 & A3B3 \\
A4B4 & A5B5 & A6B6 \\
A7B7 & A8B8 & A9B9 \\
\end{bmatrix}
$$
\noindent\textbf{PROGRAMACION EN PYTHON} \\
\begin{code}[caption= Operacion matricial en python, label=default]
import numpy
print("MULTIPLICACION DE MATRICES")
r1=int(input('numero de filas de la matriz 1 '))
c1=int(input('Numero de columnas de la matriz 1 '))
r2=int(input('Numero de filas de la matriz 2 '))
c2=int(input('Numero de columnas de la matriz 2 '))
#verificar si se puede hacer la multiplicacion
if (c1 != r2):
print("No se puede hacer la multiplicacion")
sys.exit()
matriz1=numpy.zeros((r1,c1))
matriz2=numpy.zeros((r2,c2))
matrizr=numpy.zeros((r1,c2))
print("Introduce los elementos de la matriz 1")
for r in range(0,r1):
for c in range (0,c1):
matriz1[r,c]=input("Elemento a["+str(r+1)+str(c+1)+"]")
print("Introduce los elementos de la matriz 2")
for r in range(0,r2):
for c in range (0,c2):
matriz2[r,c]=input("Elemento a["+str(r+1)+str(c+1)+"]")
#operaciones de multiplicacion
for r in range (0,r1):
for c in range (0,c2):
for k in range (0,r2):
matrizr[r,c]+=matriz1[r,k]*matriz2[k,c]
print("RESULTADO")
print(matrizr)
\end{code}
\subsection{Resultado obtenido al ejecutar el codigo}
\begin{code}[caption= Resultado de ejecutar el codigo, label=default]
MULTIPLICACION DE MATRICES
numero de filas de la matriz 1 3
Numero de columnas de la matriz 1 2
Numero de filas de la matriz 2 2
Numero de columnas de la matriz 2 3
Introduce los elementos de la matriz 1
Elemento a[11]10
Elemento a[12]11
Elemento a[21]10
Elemento a[22]12
Elemento a[31]13
Elemento a[32]12
Introduce los elementos de la matriz 2
Elemento a[11]15
Elemento a[12]16
Elemento a[13]12
Elemento a[21]13
Elemento a[22]14
Elemento a[23]15
RESULTADO
[[293. 314. 285.]
[306. 328. 300.]
[351. 376. 336.]]
\end{code}
def h(x):
return np.sin(x)
g= lambda x: np.cos(x)
x=np.linspace(0,20,200)
plt.plot(x,h(x),'b',label='seno')
plt.plot(x,g(x),'g',label='coseno')
plt.xlabel('X')
plt.ylabel('Y')
plt.title('grafica de seno y coseno')
plt.legend(loc=4)
plt.grid()
\end{code}
\noindent\textbf{Grafica resultante} \\
cuando se ejecuta la programacion en python se genera la siguiente grafica:
\begin{figure}[h!]
\centering
\includegraphics[scale=1.2]{se-co.png}
\caption{grafica resultante}
\label{fig:se-co}
\end{figure}
\bibliographystyle{plain}
\bibliography{references}
\end{document}