Accelerating the pace of engineering and science

# Documentation

## Variable Precision Arithmetic

This example shows how to use variable-precision arithmetic using Symbolic Math Toolbox™.

Compute 19/81 to 70 digits. Notice the repeated pattern of digits. "vpa" stands for variable precision arithmetic.

```digits(70);
vpa(19/81)
```
```
ans =

0.2345679012345679012345679012345679012345679012345679012345679012345679

```

Compute pi to 780 digits. Notice the string of 9's near the end.

```digits(780);
vpa(pi)
```
```
ans =

3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127372458700660631558817488152092096282925409171536436789259036001133053054882046652138414695194151160943305727036575959195309218611738193261179310511854807446237996274956735188575272489122793818301194912983367336244065664308602139494639522473719070217986094370277053921717629317675238467481846766940513200056812714526356082778577134275778960917363717872146844090122495343014654958537105079227968925892354201995611212902196086403441815981362977477130996051870721134999999837297804995

```

Compute exp(sqrt(163)*pi) to 25 digits.

```digits(25);
f = exp(sqrt(sym(163))*sym(pi));
vpa(f)
```
```
ans =

262537412640768744.0

```

The value might be an integer.

Compute the same value to 40 digits.

```digits(40);
vpa(f)
```
```
ans =

262537412640768743.9999999999992500725972

```

So, the value is close to, but not exactly equal to, an integer.

Compute 70 factorial with 200 digit arithmetic.

```digits(200);
f = vpa(factorial(sym(70)))
```
```
f =

11978571669969891796072783721689098736458938142546425857555362864628009582789845319680000000000000000.0

```

How many digits in 70!?

```find(char(f)=='.') - 1
```
```ans =

101

```

Compute the eigenvalues of the fifth order magic square to 50 digits.

```digits(50)
A = sym(magic(5))
e = eig(vpa(A))
```
```
A =

[ 17, 24,  1,  8, 15]
[ 23,  5,  7, 14, 16]
[  4,  6, 13, 20, 22]
[ 10, 12, 19, 21,  3]
[ 11, 18, 25,  2,  9]

e =

65.0
21.276765471473795530626426697974230836132173556001
13.126280930709218802525643085949143823222734386507
-13.126280930709218802525643085949143823222734386507
-21.276765471473795530626426697974230836132173556001

```