## MATLAB and Maple Code for Estimating the Completely Bounded Norm of a Map

Here are some scripts that can be used to estimate (or in some cases, calculate exactly) the completely bounded norm of linear maps. The algorithm that these scripts are based on was described in this paper. If the given map is completely positive, then the exact cb norm of that map is calculated and given as the output of these scripts. If the given map is not completely positive, then an upper bound is given for the completely bounded norm — run the script with a high number of iterations to obtain a tighter upper bound.

### MATLAB Script

This is the recommended script for estimating the cb norm of a map as it is currently the fastest implementation of the algorithm that I have. The script consists of one .m file (zipped in a .zip archive) for MATLAB. After extracting this file and putting it in your MATLAB scripts directory, you will be able to use the CBNorm function; an example of how to use this function is provided here:

```>> A(:,:,1) = diag([exp(-5*i*pi/4),exp(-i*pi),exp(-3*i*pi/4)]);
>> A(:,:,2) = eye(3);
>> B(:,:,1) = diag([exp(5*i*pi/4),exp(i*pi),exp(3*i*pi/4)]);
>> B(:,:,2) = -eye(3);
>> CBNorm(A,B,1000)

ans =
1.4390```

In the above example, the completely bounded norm of the map was estimated based on 1 000 iterations of the algorithm (which took just under half of a second on my laptop). We know from Theorem 26 that the actual completely bounded norm of that map is sqrt(2), so the relative error of our estimate is about 1.75%.

### Maple Script

This is an alternative script for estimating the cb norm of a map for people who either can not use the MATLAB script above or simply prefer working with Maple. This .zip archive contains three files: a Maple 8 worksheet, a Maple 11 worksheet, and a plain text version of the script. Example code for how to use the script is provided on the Maple worksheets, but here is the example code if you are loading in the procedures from the plain text file:

```> NumOps:=2:
> NumIts:=100:
> A:=Array(1..NumOps):
> B:=Array(1..NumOps):
> A:=DiagonalMatrix([exp(-5*I*Pi/4),exp(-I*Pi),exp(-3*I*Pi/4)]):
> A:=IdentityMatrix(3):
> B:=DiagonalMatrix([exp(5*I*Pi/4),exp(I*Pi),exp(3*I*Pi/4)]):
> B:=-IdentityMatrix(3):
> CBNorm(A,B,NumIts,NumOps);```

The output of the above commands was 1.4932 based on 100 iterations of the algorithm (which took about 7 seconds on my laptop). We know from Theorem 26 that the actual completely bounded norm of that map is sqrt(2), so the relative error of our estimate is about 5.59%.