iTranslated by AI
Getting Started with Julia on Windows 11!
In this note, we will learn how to install Julia, set up the Jupyter Notebook environment, and use various packages. When setting up a Windows 11 device, please follow the steps below to finish settings such as displaying hidden files and extensions.
From Installation to Launching Julia
Julia can be installed from the Microsoft Store. We live in a great time.
- Access the link above and click
Get in Store appin the top right.
- A small window will open. Click
Installto proceed. The installation will finish automatically, so clickOpenat the end.


- There will be an installation process only for the first time (it's quick, so you might not notice), and then Julia will launch automatically.

- That was "up to the launch." Let's do a Hello, World! while we're at it.
Jupyter Notebook
Many Julia users do almost all of their work on Jupyter Notebook. Let's try using it first.
Installation
- Pressing
]on the previous screen switches to pkg mode.

- Typing
add IJuliain pkg mode installs IJulia.jl. Other packages are installed in the same way withadd ~~~, so keep that in mind.

- When the installation is finished, press Backspace. This ends pkg mode and returns you to the normal REPL mode.

- Enter
using IJulia; notebook(detached=true)in the REPL to launch Jupyter Notebook. Only the first time,install Jupyter via Conda, y/n?will be displayed, so typeyand press Enter.

- The installation will then begin, and Jupyter Notebook will launch automatically.



REPL Remembers Past Commands
Knowing this or not can make a huge difference in work efficiency and growth rate, so I believe it should be taught early on. Close the Julia window by clicking the × button and restart it.
- Press the ↑ key in the REPL to display the history of past commands.

- Press Enter to launch Jupyter Notebook again.
Hello World! on the Notebook
- Navigate to a directory of your choice. Let's use the desktop for this example.
- After moving to the directory, click "New" in the top right, select the Julia version, and create a notebook.
- A notebook file will be created, and it will automatically open in a new tab. Click "Untitled" in the top left and rename the notebook.
- Enter the title of the notebook and press "Rename".
- Enter
println("Hello World!")in the box displayed in the middle and click the play button ▷ at the top.
-
Hello World!will be displayed as the output.
How to Use Julia and Notebooks
- Try entering the following code into a notebook cell. These
xandyare called variables.x = 1means "assigning 1 to x". Please be careful as it does not mean "equal" as it does in mathematics. In Jupyter Notebook, the value of the last evaluated line is output. In this case, the value of the lastxis evaluated.
x = 1
y = 2
x = y
- Next, let's perform some simple calculations. Since the value of
zis evaluated last, 3 will be output. Using justzwill produce the same result. If you useprintln(z), it will be output even in the middle of the code.

x = 1
y = 2
z = x + y
- Trigonometric and exponential functions can be used without any special preparation. Pi can be used as
πorpi.π/2means π divided by 2.
sin(π/2)
-
You can also use Markdown and LaTeX notation. While the cell is selected, click the dropdown that says "Code" at the top. There is an option for Markdown, so click that. The left side of the cell will change slightly.


-
Enter the following content into this cell. Headings are written as
# Titlewith a space after#or##. You can use formulas like LaTeX by enclosing them in$$. For Markdown notation, please refer to this guide. Then, press the play button ▶ to see it replaced with headings, text, and formulas.


# Markdown Example
For example, the addition formula is written as follows.
$$
\sin(\alpha+\beta) = \sin\alpha \cdot \cos\beta + \cos\alpha \cdot \sin\beta
$$
- Finally, let's numerically verify the addition theorem. You can also use Greek letters for variables. Not just in Julia, but in computer calculations in general, results calculated through different methods rarely match perfectly down to the last digit, so you don't need to worry about it. If you're really curious, try the same calculation in another programming language.
α = 1
β = 2
println( sin(α+β) )
println( sin(α)*cos(β)+cos(α)*sin(β) )
Using Various Packages
Plotting Graphs
- In Julia, you can plot functions and arrays using the
Plots.jlpackage. If you want to plot things like CSV files, you need to store them in an array first.
using Pkg
Pkg.add("Plots")
using Plots
plot(sin)
Solving Optimization Problems
-
Optim.jlallows you to solve optimization problems using various methods. We will find the minimum value and minimum point of using the steepest descent method.f(x)=(x+2)^2+1
using Pkg
Pkg.add("Optim")
using Optim
f(x) = (x[1] + 2.0)^2 + 1
x0 = [5.0]
optimize(f, x0, method=GradientDescent())
Solving Eigenvalue Problems
- Using
LinearAlgebra.jl, you can easily find the eigenvalues and eigenvectors of a matrix. It's reliable because LAPACK is running behind the scenes.LinearAlgebra.jlis installed by default.
using LinearAlgebra
A = [-4 0 6;
-3 2 3;
-3 0 5]
eigen(A)
Using Special Functions
- Julia provides packages for using various special functions.
using Pkg
Pkg.add("SpecialFunctions")
using SpecialFunctions
gamma(1/2)^2
Introduction of Other Articles
- Various other notes are available, so feel free to study those that interest you.
- Lecture materials on numerical computation using Julia
http://www.cas.cmc.osaka-u.ac.jp/~paoon/Lectures/2020-8Semester-NA-basic/ - Learn quantum mechanics while using Julia
https://github.com/cometscome/QM - Learn calculus while using Julia
https://github.com/genkuroki/Calculus#微分積分学 - Learn statistics while using Julia
https://github.com/genkuroki/Statistics#統計学
Ending the Notebook
- Let's finish by selecting
File > Close and Haltfrom the top left. If you only close the tab, the kernel will still be running.
The notebook created this time can be downloaded from the link below.
Discussion