How to reproduce this example in Julia
M = [1 -1;
1 1]
2×2 Array{Int64,2}:
1 -1
1 1
julia> x0 = [1, 3]
2-element Array{Int64,1}:
1
3
julia> c = M \ x0
2-element Array{Float64,1}:
2.0
1.0
julia> c1, c2 = c;
julia> c1
2.0
julia> c2
1.0
How to correct the result
Julia>val, vec=eigen(A)
15:45:46->>Eigen{Float64,Float64,Array{Float64,2},Array{Float64,1}}
values:
2-element Array{Float64,1}:
1.0
3.0
vectors:
2×2 Array{Float64,2}:
-0.707107 -0.707107
-0.707107 0.707107
the eigenvectors differ from the result shown in the example!!!
I mean, your final solution in the screenshot is e^t * [2, 2] + e^3t * [-1, 1]
.
Using eigen
:
julia> A = [2 -1;
-1 2];
julia> v, M = eigen(A);
julia> c = M \ [1, 3]
2-element Array{Float64,1}:
-2.8284271247461903
1.4142135623730951
julia> c[1] * M[:, 1]
2-element Array{Float64,1}:
2.0
2.0
julia> c[2] * M[:, 2]
2-element Array{Float64,1}:
-1.0
1.0
which is the same.
In other words, it’s just a difference in how you scale the coefficient.
the eigenvectors differ from the result are
Example_EigenVectors=[1 -1;1 1]
09:37:55->>2×2 Array{Int64,2}:
1 -1
1 1
And I am getting:
F=eigen(A);
F.values
09:34:16->>2-element Array{Float64,1}:
1.0
3.0
F.vectors
09:34:22->>2×2 Array{Float64,2}:
-0.707107 -0.707107
-0.707107 0.707107
Are you claiming they are not eigenvectors? See e.g:
julia> A * M[:, 1] - v[1] * M[:, 1]
2-element Array{Float64,1}:
0.0
0.0
julia> A * M[:, 2] - v[2] * M[:, 2]
2-element Array{Float64,1}:
0.0
0.0
Please see here:Another Solution of (b)
from this site I took the example!!!
Eigenvectors can be scaled and still be eigenvectors. If you think about A*v - c*v = 0
, any scaling of v
will still satisfy the equation. Here, Julia has given you the eigenvector with a unitary norm, while in that example they give you one with integers (because it’s easier to write). The only difference, in the end, is that you get different coefficients when you solve them based on the initial conditions of the ODE which compensates for the choice of scaling in the eigenvector. The final solution to the ODE is of course the same.