# Mathematics

Most of the below functionality described in the core MATLAB Mathematics documentation has equivalent, often identical, functionality (more often that not with the same syntax) described in the Base.Mathematics section of the Julia manual. Specific equivalents are identified below; often these have the same names as in Matlab, otherwise the Julia equivalent name is noted.

## Elementary Math

### Arithmetic

See Arithmetic Operators in the Julia manual. Note that in Julia the operators are themselves methods and can be used anywhere a method can. See e.g. the example in the documentation for Base.map.

### Trigonometry

See Trigonometric and Hyperbolic functions in the Julia manual.

### Exponents and Logarithms

See Powers, logs and roots in the Julia manual.

### Complex Numbers

See Complex Numbers in the Julia manual.

### Discrete Math

#### Others

###### perms All possible permutations

The Julia Permutations.permutations(a) function ( Permutations.jl package) returns an iterator object (because the number of permutations can be very large), and in lexicographic order rather than reverse lexicographic. Therefore a drop-in equivalent could be constructed as follows:

julia> perms(a) = reverse(collect(permutations(a)))
perms (generic function with 1 method)

julia> perms([2,4,6])
6-element Array{Array{Int64,1},1}:
[6, 4, 2]
[6, 2, 4]
[4, 6, 2]
[4, 2, 6]
[2, 6, 4]
[2, 4, 6]
###### rat Rational fraction approximation, rats Rational output

There doesn't appear to be a direct Julia equivalent of these, but note that unlike Matlab, Julia has a native Rational Number type .

### Polynomials

See the Polynomials.jl package. Note that this package provides a proper type for polynomials, Polynomials.Poly, while in Matlab a polynomial of degree ${\displaystyle n}$is represented by a vector of length ${\displaystyle n+1}$whose elements are the coefficients in descending powers of the polynomial.

#### polyfit Polynomial curve fitting

Polynomials.polyfit provides comparable basic functionality--the single output argument form of the Matlab function--although it lacks the additional error estimate and centering/scaling features.

#### roots Polynomial roots

Polynomials.roots provides roots with multiplicity.

#### polyval Polynomial evaluation

See Base.Math.@evalpoly in the Julia Manual.

### Constants and Test Matrices

#### Constants

See General Number Functions and Constants in the Julia manual.

#### i, j Imaginary unit

In Julia, im is equivalent; this allows i and j to be used as e.g. loop indices without conflict.

#### pi Ratio of circle's circumference to its diameter

Also available as pi in Julia as well as \piTab ↹${\displaystyle \pi }$

#### Test Matrices

See the MatrixDepot.jl package; most of the matrices in gallery and all the rest below are available in that package, plus some additional ones.

### Linear Algebra

See Linear Algebra in the Julia manual.

## Numerical Integration and Differential Equations

See DifferentialEquations.jl. In particular see the section Translations from MATLAB/Python/R.

## Computational Geometry

See the JuliaGeometry GitHub organization.

### Elementary Polygons

The Julia package GeometricalPredicates.jl provides some similar functionality.