Taller de math-
ematica
Dinámica de Medios Deformables
Semestre 2022-1
Lorenzo Montzon Solis
419002770
10-12-2021
Comenzamos definiendo algunas variables, estas variables pueden ser de cualquier tipo, y
deben escribirse como los siguientes ejemplos (puede ser cualquier nombre). Debemos decir
que como se maneja este notebook es como “pregunta-respuesta” por lo que es necesario
presionar SHIFT+ENTER para que nos arroje esa respuesta.
In[11]:= x1 = 120
Out[11]= 120
Nuestra variable puede ser de cualquier caracter, una palabra por ejemplo.
In[12]:= x2 = hola
Out[12]= hola
Tambien podemos definir varias variables a la vez
In[8]:= x3 = 350
x4 = 750
Out[8]= 350
Out[9]= 750
In[5]:= variable5 = 7
Printed by Wolfram Mathematica Student Edition
2 Taller de [Link]
Out[5]= 7
Ahora vamos a operar algunas de estas variables, acción que podemos realizar con los simbolos conoci-
dos de “+” , ”-” , ” * ” , ” / ”, “ ^ ”.
Las variables que definimos van siendo guardadas y podemos utilizarlas.
In[22]:= x1 * x3
Out[22]= 42 000
In[24]:= x4 * variable5
Out[24]= 5250
Tambien podemos definir una variable a partir de una operación.
In[10]:= operacion1 = x1 * x3
Out[10]= 42 000
In[15]:= operacion2 = x1 * x2
Out[15]= 120 hola
In[16]:= operacion3 = x1 + x2
Out[16]= 120 + hola
In[17]:= operacion4 = x4 / variable5
750
Out[17]=
7
Ahora definimos una lista, para hacerlo seguimos el siguiente formato “nombre de la lista” = {eleme-
nto1, elemento2, elemento3, ..., elemento n}
In[18]:= lista1 = {1, 2, 3, 4, hola, x1, "$$$$"}
Out[18]= {1, 2, 3, 4, hola, 120, $$$$}
In[19]:= lista2 = {23, 45, 56, 12}
Out[19]= {23, 45, 56, 12}
También podemos realizar operaciones con listas tal como podemos ver en los siguientes ejemplos.
In[20]:= lista1 * 2
Out[20]= {2, 4, 6, 8, 2 hola, 240, 2 $$$$}
In[21]:= lista1 * lista1
Out[21]= 1, 4, 9, 16, hola2 , 14 400, $$$$2
Ahora conociendo las listas, podemos hacer una “lista de listas”
Printed by Wolfram Mathematica Student Edition
Taller de [Link] 3
In[25]:= m1 = {{1, 2, 3}, {5, 7, 6}, {8, 7, 9}}
Out[25]= {{1, 2, 3}, {5, 7, 6}, {8, 7, 9}}
Y podemos darle forma de matriz con el siguiente comando: “nombre de la matriz”= “nombre de
nuestra lista de listas” //MatrixForm
!! Es necesario escribir bien “MatrixForm” ya que de otra forma nos tomará esto como una variable
nueva.
In[30]:= matriz1 = m1 // MatrixForm
forma de matriz
Out[30]//MatrixForm=
1 2 3
5 7 6
8 7 9
In[28]:= m2 = {{2345, 135, 134}, {1234, 8765, 45}, {876, 367, 4656}}
matriz2 = m2 // MatrixForm
forma de matriz
Out[28]= {{2345, 135, 134}, {1234, 8765, 45}, {876, 367, 4656}}
Out[29]//MatrixForm=
2345 135 134
1234 8765 45
876 367 4656
Algo muy importante es que podemos operar estas “listas de listas”
SUMAR
In[31]:= m3 = m1 + m2
Out[31]= {{2346, 137, 137}, {1239, 8772, 51}, {884, 374, 4665}}
Este resultado lo podemos represantar como matriz.
In[32]:= matriz3 = m3 // MatrixForm
forma de matriz
Out[32]//MatrixForm=
2346 137 137
1239 8772 51
884 374 4665
PRODUCTO ESCALAR
In[33]:= m4 = m1 * m2
Out[33]= {{2345, 270, 402}, {6170, 61 355, 270}, {7008, 2569, 41 904}}
Printed by Wolfram Mathematica Student Edition
4 Taller de [Link]
In[34]:= matriz4 = m4 // MatrixForm
forma de matriz
Out[34]//MatrixForm=
2345 270 402
6170 61 355 270
7008 2569 41 904
OBTENER DETERMINANTE
In[35]:= Det[m1]
determinante
Out[35]= - 36
INVERSO DE UNA MATRIZ
In[37]:= in = Inverse[m1]
matriz inversa
7 1 1 1 5 1 7 1 1
- ,- , , - , , - , , - ,
12 12 4 12 12 4 12 4 12
In[38]:= matriz5 = in // MatrixForm
forma de matriz
Out[38]//MatrixForm=
7 1 1
- -
12 12 4
1 5 1
- -
12 12 4
7 1 1
-
12 4 12
PRODUCTO ENTRE MATRICES
In[40]:= m6 = m1.m2
Out[40]= {{7441, 18 766, 14 192}, {25 619, 64 232, 28 921}, {35 282, 65 738, 43 291}}
In[41]:= matriz6 = m6 // MatrixForm
forma de matriz
Out[41]//MatrixForm=
7441 18 766 14 192
25 619 64 232 28 921
35 282 65 738 43 291
MATRIZ TRANSPUESTA
In[42]:= m7 = Transpose[m1]
transposición
Out[42]= {{1, 5, 8}, {2, 7, 7}, {3, 6, 9}}
Printed by Wolfram Mathematica Student Edition
Taller de [Link] 5
In[43]:= matriz7 = m7 // MatrixForm
forma de matriz
Out[43]//MatrixForm=
1 5 8
2 7 7
3 6 9
In[44]:= Eigenvalues[m1]
autovalores
Out[44]= 16.7… , 1.63… , -1.32…
In[45]:= Eigenvectors[m1]
autovectores
Out[45]= 0.289… , 0.768… , 1, 0.307… , -1.40… , 1, -1.39… , 0.114… , 1
In[46]:= Eigensystem[m1] // MatrixForm
autovalores y autovecto⋯ forma de matriz
Out[46]//MatrixForm=
16.7… 1.63… -1.32…
0.289… , 0.768… , 1 0.307… , -1.40… , 1 -1.39… , 0.114… , 1
Ahora, siguiendo con la linea de mostrar herramientas de primera mano para actividades matematicas
que nos ofrece este lenguaje, veremos como se definen las funciones.
Definimos una función siguiendo el siguiente formato: “nombre de la función”[variable1_,vari-
able2_]:=función.
Tambien podemos graficar estas funciones siguiendo este formato: Plot [ { función [ x ] } ,{ variable1 ,
inicio de rango , fin de rango }]
In[54]:= funcion1[x_] := x ^ (1 / 2)
Plot[{funcion1[x]}, {x, - 5, 5}]
representación gráfica
2.0
1.5
Out[55]=
1.0
0.5
-4 -2 2 4
También es posible graficar varias funciones en un mismo plano.
Printed by Wolfram Mathematica Student Edition
6 Taller de [Link]
Aqui un ejemplo de dos funciones en un mismo plano.
In[58]:= funcion2[x_] := x ^ 7
Plot[{funcion1[x], funcion2[x]}, {x, - 2, 2}]
representación gráfica
Out[59]=
-2 -1 1 2
-2
-4
Un ejemplo de como se grafican varias funciones.
In[72]:= funcion3[x_] := E ^ x
número e
funcion4[x_] := Sin[x]
seno
Plot[{funcion1[x], funcion2[x], funcion3[x], funcion4[x]}, {x, - 3, 3}]
representación gráfica
Out[74]=
-3 -2 -1 1 2 3
-5
Ahora graficamos una superficie (en 3D)
Printed by Wolfram Mathematica Student Edition
Taller de [Link] 7
In[102]:= funcion5[x_, y_] := Sin[x] + Cos[y]
seno coseno
Plot3D[funcion5[x, y], {x, - 10, 10}, {y, - 10, 10}]
representación gráfica 3D
Out[103]=
Añadiremos color a la superficie anterior agregando Plot3D[funcion5[x,y],{x,-10,10},{y,-10,10},Color-
Function”Rainbow”]
In[104]:= Plot3D[funcion5[x, y], {x, - 10, 10}, {y, - 10, 10}, ColorFunction "Rainbow"]
representación gráfica 3D función de color
Out[104]=
Printed by Wolfram Mathematica Student Edition