# How to reproduce this example

**URL:** https://discourse.julialang.org/t/how-to-reproduce-this-example/48296
**Category:** New to Julia
**Tags:** linearalgebra
**Created:** [October 13, 2020, 12:31pm UTC](https://discourse.julialang.org/t/how-to-reproduce-this-example/48296 "2020-10-13T12:31:43Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![HerAdri](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heradri/32/5816_2.png) [@HerAdri](https://discourse.julialang.org/u/HerAdri)
#### Post date: [October 13, 2020, 12:31pm UTC](https://discourse.julialang.org/t/how-to-reproduce-this-example/48296/1 "2020-10-13T12:31:43Z")

</div>

How to reproduce this example in Julia

 ![reproducirJulia](https://global.discourse-cdn.com/julialang/original/3X/a/2/a24fac4f2f6b098480443019318b9c5eac0e4884.jpeg)

---

<div class="post-metadata">

### Author: ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)
#### Post date: [October 13, 2020, 12:46pm UTC](https://discourse.julialang.org/t/how-to-reproduce-this-example/48296/2 "2020-10-13T12:46:35Z")

</div>

```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

```

---

<div class="post-metadata">

### Author: ![HerAdri](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heradri/32/5816_2.png) [@HerAdri](https://discourse.julialang.org/u/HerAdri)
#### Post date: [October 13, 2020, 12:49pm UTC](https://discourse.julialang.org/t/how-to-reproduce-this-example/48296/3 "2020-10-13T12:49:17Z")

</div>

How to correct the result

```julia
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!!!

---

<div class="post-metadata">

### Author: ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)
#### Post date: [October 13, 2020, 1:02pm UTC](https://discourse.julialang.org/t/how-to-reproduce-this-example/48296/4 "2020-10-13T13:02:50Z")

</div>

I mean, your final solution in the screenshot is `e^t * [2, 2] + e^3t * [-1, 1]`.

Using `eigen`:

```julia
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.

---

<div class="post-metadata">

### Author: ![HerAdri](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heradri/32/5816_2.png) [@HerAdri](https://discourse.julialang.org/u/HerAdri)
#### Post date: [October 14, 2020, 7:00am UTC](https://discourse.julialang.org/t/how-to-reproduce-this-example/48296/5 "2020-10-14T07:00:16Z")

</div>

> [@kristoffer.carlsson](#):
>
> `c[2] * M[:, 2]`

the eigenvectors differ from the result are

```julia
Example_EigenVectors=[1 -1;1 1]
09:37:55->>2×2 Array{Int64,2}:
 1 -1
 1 1

```

 ![reproducirJulia](https://global.discourse-cdn.com/julialang/original/3X/0/e/0e8726204855511f77dfd5b180fd27c3dec7a3c4.jpeg)

And I am getting:

```julia
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

```

---

<div class="post-metadata">

### Author: ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)
#### Post date: [October 14, 2020, 7:29am UTC](https://discourse.julialang.org/t/how-to-reproduce-this-example/48296/6 "2020-10-14T07:29:13Z")

</div>

> [@HerAdri](#):
>
> the eigenvectors differ from the result are

Are you claiming they are not eigenvectors? See e.g:

```julia
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

```

---

<div class="post-metadata">

### Author: ![HerAdri](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heradri/32/5816_2.png) [@HerAdri](https://discourse.julialang.org/u/HerAdri)
#### Post date: [October 14, 2020, 7:51am UTC](https://discourse.julialang.org/t/how-to-reproduce-this-example/48296/7 "2020-10-14T07:51:26Z")

</div>

Please see here:[Another Solution of (b)](https://yutsumura.com/solve-the-linear-dynamical-system-fracmathrmdmathbfxmathrmdt-amathbfx-by-diagonalization/?subscribe=many_pending_subs#blog_subscription-4)  
from this site I took the example!!!

---

<div class="post-metadata">

### Author: ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)
#### Post date: [October 14, 2020, 8:06am UTC](https://discourse.julialang.org/t/how-to-reproduce-this-example/48296/8 "2020-10-14T08:06:37Z")

</div>

> [@HerAdri](#):
>
> 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.
