In [1]:
A=rand(3,3)


Out[1]:
3x3 Array{Float64,2}:
 0.916454  0.312883  0.0291289
 0.540449  0.599044  0.177166 
 0.111509  0.557226  0.337076 

In [5]:
f(x)=x^2+4


Out[5]:
f (generic function with 1 method)

In [6]:
f(2)


Out[6]:
8

In [8]:
y=3+6im
z=3+5im
z+y


Out[8]:
6 + 11im

In [9]:
w=3//4
typeof(w)


Out[9]:
Rational{Int64} (constructor with 1 method)

In [11]:
#we can do interesting things like
w^2


Out[11]:
9//16

In [12]:
methods(//)


Out[12]:
8 methods for generic function //:

In [13]:
3+-(32)


Out[13]:
-29

In [14]:
l=[1,2,3]


Out[14]:
3-element Array{Int64,1}:
 1
 2
 3

In [15]:
l'*l


Out[15]:
1-element Array{Int64,1}:
 14

In [16]:
m=[3.5,2,6.1]


Out[16]:
3-element Array{Float64,1}:
 3.5
 2.0
 6.1

In [17]:
n=[3,"Hola"]


Out[17]:
2-element Array{Any,1}:
 3      
  "Hola"

In [18]:
t=[1:5]


Out[18]:
5-element Array{Int64,1}:
 1
 2
 3
 4
 5

In [20]:
#Para imdicar índices
t[2]


Out[20]:
2

In [23]:
t+t


Out[23]:
5-element Array{Int64,1}:
  2
  4
  6
  8
 10

In [24]:
names(t)


Out[24]:
0-element Array{Any,1}

In [25]:
methods(push!)


Out[25]:
36 methods for generic function push!:

In [26]:
#IMPORTANTE
p=[3,4,5]
push!(p,6)


Out[26]:
4-element Array{Int64,1}:
 3
 4
 5
 6

In [30]:
l.*m


Out[30]:
3-element Array{Float64,1}:
  3.5
  4.0
 18.3

In [31]:
#Producto punto
dot(l,m)


Out[31]:
25.799999999999997

In [32]:
M=[2 1;3 3]


Out[32]:
2x2 Array{Int64,2}:
 2  1
 3  3

In [1]:
i=0
while i<5 
    print("$i\t")
    i += 1
end


0	1	2	3	4	

In [3]:
total=0
for i=1:10
    total+=i
end
println("La suma es $total")


La suma es 55

In [4]:
?dot


INFO: Loading help data...
dot (generic function with 13 methods)

In [1]:
a=3
a<5 && println("Pequeño")# if then
a>10 || println("Pequeño")# if not then


Pequeño
Pequeño

In [3]:
a==4 ? println("Hola") : println("Falso")


Falso

In [4]:
#ARREGLOS
squares=[i^2 for i in [1:2:10,7]]


Out[4]:
6-element Array{Any,1}:
  1
  9
 25
 49
 81
 49

In [1]:
sums=[i+j for i=1:5,j=1:5]#Forma compacta de crear marices


Out[1]:
5x5 Array{Int64,2}:
 2  3  4  5   6
 3  4  5  6   7
 4  5  6  7   8
 5  6  7  8   9
 6  7  8  9  10

In [2]:
sums=[i+j+k for i=1:5,j=1:5,k=1:5]#Arreglo de 5x5x5


Out[2]:
5x5x5 Array{Int64,3}:
[:, :, 1] =
 3  4  5   6   7
 4  5  6   7   8
 5  6  7   8   9
 6  7  8   9  10
 7  8  9  10  11

[:, :, 2] =
 4  5   6   7   8
 5  6   7   8   9
 6  7   8   9  10
 7  8   9  10  11
 8  9  10  11  12

[:, :, 3] =
 5   6   7   8   9
 6   7   8   9  10
 7   8   9  10  11
 8   9  10  11  12
 9  10  11  12  13

[:, :, 4] =
  6   7   8   9  10
  7   8   9  10  11
  8   9  10  11  12
  9  10  11  12  13
 10  11  12  13  14

[:, :, 5] =
  7   8   9  10  11
  8   9  10  11  12
  9  10  11  12  13
 10  11  12  13  14
 11  12  13  14  15

In [3]:
rand()#Numero uniformemente distribuido entre 0 y 1


Out[3]:
0.12404958787347886

In [4]:
rand(5)


Out[4]:
5-element Array{Float64,1}:
 0.359922 
 0.952802 
 0.445792 
 0.0930482
 0.71408  

In [5]:
rand(5,5)


Out[5]:
5x5 Array{Float64,2}:
 0.221052  0.454196  0.3394     0.693485   0.377514
 0.80151   0.72386   0.29839    0.194656   0.710811
 0.896861  0.761646  0.488731   0.0736582  0.900251
 0.851037  0.543305  0.102537   0.877466   0.646387
 0.373893  0.577486  0.0366432  0.194849   0.847138

In [11]:
M=[2 1;1 1]
v=[1,1]
M*v


Out[11]:
2-element Array{Int64,1}:
 3
 2

In [13]:
@which M*v#IMPORTANTE: Cual es el Método que esta utilizando para la miltiplicación


Out[13]:
*{T,S}(A::AbstractArray{T,2},x::AbstractArray{S,1}) at linalg/matmul.jl:71

In [28]:
M=[2 1;1 1]
w=[0,1]
lambda=0
k=0
for i=1:10#¿Porque desborda con i=100?
    k=w[2]
    w=M*w
    lambda=w[2]/k
end
println("Lambda sería $lambda")


Lambda sería 2.618033813400125

In [27]:
eigmax(M)


Out[27]:
2.618033988749895

In [ ]: