Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Julia 1.0 Programming Complete Reference Guide

You're reading from   Julia 1.0 Programming Complete Reference Guide Discover Julia, a high-performance language for technical computing

Arrow left icon
Product type Course
Published in May 2019
Publisher
ISBN-13 9781838822248
Length 466 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Ivo Balbaert Ivo Balbaert
Author Profile Icon Ivo Balbaert
Ivo Balbaert
Arrow right icon
View More author details
Toc

Table of Contents (18) Chapters Close

Preface 1. Installing the Julia Platform FREE CHAPTER 2. Variables, Types, and Operations 3. Functions 4. Control Flow 5. Collection Types 6. More on Types, Methods, and Modules 7. Metaprogramming in Julia 8. I/O, Networking, and Parallel Computing 9. Running External Programs 10. The Standard Library and Packages 11. Creating Our First Julia App 12. Setting Up the Wiki Game 13. Building the Wiki Game Web Crawler 14. Adding a Web UI for the Wiki Game 15. Implementing Recommender Systems with Julia 16. Machine Learning for Recommender Systems 17. Other Books You May Enjoy

Installing and working with IJulia

IJulia (https://github.com/JuliaLang/IJulia.jl) is a combination of the Jupyter Notebook interactive environment (http://jupyter.org/) with a Julia language backend. It allows you to work with a powerful graphical notebook (which combines code, formatted text, math, and multimedia in a single document) with a regular REPL. Detailed instructions for installation can be found at the GitHub page for IJulia (https://github.com/JuliaLang/IJulia.jl) and in the Julia at MIT notes (https://github.com/stevengj/julia-mit/blob/master/README.md). Add the IJulia package in the REPL package mode with add IJulia.

Then, whenever you want to use it, start up a Julia REPL and type the following commands:

using IJulia 
notebook()

If you want to run it from the command line, type:

jupyter notebook 

The IJulia dashboard should look as follows:

The IJulia dashboard

You should see the Jupyter logo in the upper-left corner of the browser window. Julia code is entered in the input cells (the input can be multiline) and then executed with Shift + Enter

Here is a small example (ijulia-example.jl):

The output should be something as follows:

An IJulia session example

In the first input cell, the value of b is calculated from a:

a = 5 
b = 2a^2 + 30a + 9 

In the second input cell, we use PyPlot. Install this package with add PyPlot in the REPL package mode, and by issuing using PyPlot in the REPL.

The range(0,stop=5,length=101) command defines an array of 100 equally spaced values between 0 and 5; y is defined as a function of x and is then shown graphically with the plot command, as follows:

using PyPlot 
x = range(0,stop=5,length=101)
y = cos.(2x .+ 5) plot(x, y, linewidth=2.0, linestyle="--") title("a nice cosinus") xlabel("x axis") ylabel("y axis")

Save a notebook in file format (with the .ipynb extension) by downloading it from the menu.

You have been reading a chapter from
Julia 1.0 Programming Complete Reference Guide
Published in: May 2019
Publisher:
ISBN-13: 9781838822248
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £16.99/month. Cancel anytime