This site is supported by donations to The OEIS Foundation.

# Wolfram Mathematica

This article needs more **work**.

Please help by expanding it!

**Wolfram Mathematica**, from Wolfram Research Inc., is a computer algebra system used for numerical and symbolic computations. It also has word processing and typesetting features, as the program is intended to be not just a computational engine but also a tool for documenting mathematical research—hence Mathematica documents are called "notebooks" and have a `*.nb` file extension. (Starting with Mathematica 8, one can also save notebooks as "Computable Documents" that have a `*.cdf` (Computable Document Format) file extension and leverage "the power and flexibility of the Mathematica language with the wide distribution provided by a public format."^{[1]})

## Contents

## Some number theoretic functions

### Prime numbers

The basic prime-related functions in Mathematica are `Prime[n]`, `PrimePi[x]` and `PrimeQ[n]`, which are the ^{th} prime function, the prime counting function and the characteristic function of prime numbers respectively.

**PrimePi[998.7654]**`168`**Prime[168]**`997`**PrimeQ[%]**`True`

In that last example we showed ` %`, the shortcut for the previous output, like the ANS key on a calculator. Closely allied to these functions is

`FactorInteger[n]`, which returns a list of prime factors with exponents, and, if necessary, a complex unit.

- ( ===== THIS SPACE RESERVED FOR SOME STUFF ABOUT PARTITION FUNCTIONS ===== )
^{[2]}

- ( ===== THIS SPACE RESERVED FOR SOME STUFF ABOUT BASE REP FUNCTIONS ===== )
^{[3]}

## Some sequence handling functions

In the Mathematica documentation, sequence handling is referred to as "list manipulation."

The workhorse of sequence handling is perhaps the `Table` command, which takes a function, usually of one or two variables, and iterates it through some specified values for the variables.

This example gives a few small positive integers of the form (the default starting value in Mathematica is 1; to start with 0 it must be explicitly stated)

**Table[6k + 1, {k, 20}]**`{7, 13, 19, 25, 31, 37, 43, 49, 55, 61, 67, 73, 79, 85, 91, 97, 103, 109, 115, 121}`

Another list manipulation command frequently used in the OEIS is `Select`, which goes through a list and picks out those elements that meet the specified criterion. After the previous `Table` output, we could do

**Select[%, PrimeQ]**`{7, 13, 19, 31, 37, 43, 61, 67, 73, 79, 97, 103, 109}`

`Select` is often paired with the humble and unassuming `Range` command. At first it would seem all `Range` does is give a list of consecutive integers.

**Range[10]**`{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}`

But the starting value doesn't have to be 1, nor does 1 have to be the increment value, which can even be negative if desired (in which case it's a decrement). Thus,

**Range[100, 2, -7]**`{100, 93, 86, 79, 72, 65, 58, 51, 44, 37, 30, 23, 16, 9, 2}`

gives A115020. But more usefully still, arithmetic operations can be applied to the entire sequence specifying each only once. Thus, our earlier example of , can be more compactly given as ` 6Range[20] + 1`.

There are also commands for comparing sequences, finding the elements in common, etc.

## EISFormat.m

EISFormat.m formats integer sequences in the native format expected by Neil Sloane's online encyclopedia of integer sequences. Written by Olivier Gerard and Eric W. Weisstein.

## See also

- User:Enrique Pérez Herrero/OEIS Package#Mathematica OEIS Package
- Mathematica code
- Style sheet for Mathematica programs

## Notes

- ↑ Wolfram Research, "How to Create a Computable Document Format (CDF) File" Notebooks are still the default format for Mathematica documents.
- ↑ To do.
- ↑ To do.

## External links

- Wolfram Mathematica, from Wolfram Research Inc.
- Mathics, "a free, light-weight alternative to Mathematica"