## How to use an external calculator

We will see how to use an external calculator. For example, suppose you have a reduced density operator in the read-line mode:
 > init-mixed 0.7 0.7 0.9;
> H(1 2);CN(1 2,3);
> RDO(1 2);
0.25|0><0| + 0.1|0><1| + 0.1|0><2| + 0.1|1><0| + 0.25|1><1| +
0.04|1><2| + 0.1|2><0| + 0.04|2><1| + 0.25|2><2| + 0.25|3><3|
> SvNRDO(1 2)
1.87811

As we have seen above, the von Neumann entropy of is .

This matrix can be saved and converted to the matrix in the style of Octave by the commands:

 > RDOsave(1 2, foo.matrix);
> conv-octave(foo.matrix, foo.matrix.octave);

The file foo.matrix.octave'' contains the text:
[2.500000000e-01,1.000000000e-01,1.000000000e-01,0;1.000000000e-01,2.500000000e-
01,4.000000000e-02,0;1.000000000e-01,4.000000000e-02,2.500000000e-01,0;0,0,0,2.5
00000000e-01]

Then you can calculate the von Neumann entropy also by using Octave. The Octave function to calculate for a density matrix is
%%%% The Octave function to calculate the von Neumann entropy of rho %%%%
function S = SvN(rho)
A = eig(rho);
S = 0;
for i=1:1:rows(A)
if A(i,1) ~= 0,
S += A(i,1)*log(A(i,1))/log(2);
endif
endfor
S = -S;
endfunction

This function and the rest part of the program
A=[2.500000000e-01,1.000000000e-01,1.000000000e-01,0;1.000000000e-01,2.500000000e
-01,4.000000000e-02,0;1.000000000e-01,4.000000000e-02,2.500000000e-01,0;0,0,0,2.5
00000000e-01];
SvN(A)

returns the result as shown below.
[akira@localhost transition]\$ octave foo.octave
GNU Octave, version 2.1.35 (i386-redhat-linux-gnu).
Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 John W. Eaton.
This is free software with ABSOLUTELY NO WARRANTY.
For details, type warranty'.

ans = 1.8781
`
This value is equal to the one obtained by silqcs.

root
2004-06-15