The SINTEF Matlab Reservoir Simulation Toolbox includes a GPL-licensed AD library. The usage is mostly geared towards numerical applications in subsurface flow, but the library itself is usable for more general purposes.
Here is a basic runthrough of your example as you would run it from the base directory of MRST:
startup;
% Load ad based module
mrstModule add ad-fi
val = [1; 2; 3];
x = initVariablesADI(val);
y = x.*[4; 5; 6];
disp 'Jacobian:'
full(y.jac{1})
z = sum(x.*x);
disp 'Jacobian:'
full(z.jac{1})
Jacobian:
% MRST AD also supports multiple vector valued functions
a = ones(5, 1);
b = ones(5, 1);
[a, b] = initVariablesADI(a, b);
c = a.*b + 2.*b;
full(c.jac{1})
full(c.jac{2})
There exists a work-in-progress user guide at the website, where chapter 7 has some usage of the AD library. This library is primarily geared towards problems that require all Jacobian values and is vectorized using forward mode only. It does include some nice things though, like 2d table interpolation and so on. It has been used for moderate size non-linear problems (order of 500,000 unknowns).
The non-linear solvers and components are heavily focused on reservoir applications at the moment. This part of the library is presently being rewritten and may in the future have some use outside of this specific domain. However, if you just want the AD part, the ADI class and the initVariablesADI function should be sufficient.
Disclaimer: I am one of the developers attached to this research group.