# Teaching Scientific Computing with Julia

**URL:** <https://discourse.julialang.org/t/teaching-scientific-computing-with-julia/82851>\
**Category:** Teaching & Outreach\
**Created:** [June 16, 2022, 2:32am UTC](https://discourse.julialang.org/t/teaching-scientific-computing-with-julia/82851 "2022-06-16T02:32:55Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![Bruno\_Amorim](https://avatars.discourse-cdn.com/v4/letter/b/f6c823/32.png) [@Bruno\_Amorim](https://discourse.julialang.org/u/Bruno_Amorim)\
**Post date:** [June 16, 2022, 3:24pm UTC](https://discourse.julialang.org/t/teaching-scientific-computing-with-julia/82851/9 "2022-06-16T15:24:31Z")

</div>

> [@martin.d.maas](#):
>
> As for eigensolvers, I’ve successfully used the `eigs` function from the `LinearAlgebra` package. I’m not aware of its limitations. Why should we refer to any other package?

Notice that the function `eigs` has been moved to the package `Arpack.jl`. The problems I have faced with `eigs` occur when using shift-and-inverse. Sometimes you get errors with the factorization step that is used to solve the linear problems. And there is no way to change the factorization used.

ArnoldiMethod.jl and KrylovKit.jl do not implement shift-and-inverse, but it is not easy to adapt them to do so. See for example [Spectral transformations](https://julialinearalgebra.github.io/ArnoldiMethod.jl/stable/usage/02_spectral_transformations.html) section in the docs of ArnoldiMethod.jl. However, it would be nice to have something ready out-of-the-box.

Between ArnoldiMethod.jl and KrylovKit.jl, from experience with a MSc student (computing some bandstructures from a tight-binding Hamiltonian), we found that KrylovKit.jl was more accurate (we would get “noisy” bands when using shift-and-inverse with ArnoldiMethod.jl, for the eigenvalues further away from the target). The downside of KrylovKit.jl is that it does not support in-place operations.

> [@martin.d.maas](#):
>
> For Plotting, I think Plots.jl is the standard as it has so many backends.

As I said in another [post](https://discourse.julialang.org/t/discussion-on-why-i-no-longer-recommend-julia-by-yuri-vishnevsky/81151/243) I think that for such a high level operation, such as plotting, being capable of switching backends is not such a great advantage. If you really want to fine-tune the look of a plot (and you always end up wanting to do so), you end up running into the issue of not all backends having the same features, and having to use backend dependent options. At that point, it is just better to use directly the backend.

On the other hand, for other kinds of problem, such as eigenproblems or linear problems, I think that being capable of easily changing backends/solvers is actually a useful thing. You might be writing code to solve a general problem where the eigen/linear-problem is just one of the steps. However, there might not be an ideal solver. It might depend on the size of the problem you are dealing, or you might want to easily spawn the solver for testing. So being capable of passing a solver as a function argument really makes things easy. In this respect, I think that Floops.jl does this really well.

> [@martin.d.maas](#):
>
> Now, I’m not a big fan of massive packages where you define a `problem` and then you call `solve`. I’d rather rely on a slightly more modular approach, which also makes the math more transparent, and where access to the actual code being run is easy. Especially for this goal of teaching a class.

I am not fully convinced that transforming

```julia
x = A\b

```

into

```julia
prob = LinearProblem(A, b)
sol = solve(prob)
x = sol.u

```

Is a great idea for beginners, but I guess one can write it as:

```julia
x = solve(LinearProblem(A, b)).u

```

which is a one-liner, but still a bit verbose.  
For me a notation like:

```julia
x = linearsolve(A, b, method)

```

seems more natural (before Julia I mostly used Mathematica). But I guess that when the method needs to use a cache, maybe the best option is really to use something like `problem`-`init`-`solve`.

---

_[View the full topic](https://discourse.julialang.org/t/teaching-scientific-computing-with-julia/82851)._
