None.
Open in the MATLAB editor: d04bb_example
function d04bb_example fprintf('d04bb example results\n\n'); fprintf('\nFind the derivatives of the polygamma (psi) function\n'); fprintf('using function values generated by s14ae.\n\n'); fprintf('Demonstrate the effect of successively reducing hbase.\n\n'); % Set the target location and calculate the objective value x_0 = 0.05; [f_0, ifail] = s14ae(x_0, int64(0)); % Compute the actual derivatives using s14ae for comparison actder = zeros(3, 1); for j=1:3 [actder(j), ifail] = s14ae(x_0, int64(j)); end der_comp = zeros(14, 3, 4); % Attempt 4 applications, reducing hbase by factor 0.1 each time for j=1:4 % Generate the abscissa xval using d04bb hbase = 0.025*10^(-j); [xval] = d04bb(x_0, hbase); % Calculate the corresponding objective function values fval(11) = f_0; for k=[1:10,12:21] [fval(k), ifail] = s14ae(xval(k), int64(0)); end % Call d04ba to calculate the derivative estimates [der, erest, ifail] = d04ba(xval, fval); % Store results in der_comp der_comp(:, 1, j) = hbase; der_comp(:, 2, j) = der; der_comp(:, 3, j) = erest; end % Display results for first 3 derivatives for i=1:3 fprintf('\nderivative %d calculated using s14ae: %11.4e\n', i, actder(i)); fprintf('Derivative and error estimates for derivative %d\n', i); fprintf(' hbase der(%d) erest(%d)\n', i, i); for j=1:4 fprintf(' %12.4e %12.4e %12.4e\n', der_comp(i,:,j)); end end
d04bb example results Find the derivatives of the polygamma (psi) function using function values generated by s14ae. Demonstrate the effect of successively reducing hbase. derivative 1 calculated using s14ae: 4.0153e+02 Derivative and error estimates for derivative 1 hbase der(1) erest(1) 2.5000e-03 4.0204e+02 1.3940e+02 2.5000e-04 4.0153e+02 4.9170e-11 2.5000e-05 4.0153e+02 2.1799e-10 2.5000e-06 4.0153e+02 1.1826e-09 derivative 2 calculated using s14ae: -1.6002e+04 Derivative and error estimates for derivative 2 hbase der(2) erest(2) 2.5000e-03 -1.6022e+04 5.5760e+03 2.5000e-04 -1.6002e+04 1.2831e-07 2.5000e-05 -1.6002e+04 6.0543e-06 2.5000e-06 -1.6002e+04 9.5762e-04 derivative 3 calculated using s14ae: 9.6001e+05 Derivative and error estimates for derivative 3 hbase der(3) erest(3) 2.5000e-03 9.1465e+05 -7.3750e+06 2.5000e-04 9.6001e+05 2.3718e-04 2.5000e-05 9.6001e+05 4.2253e-02 2.5000e-06 9.6001e+05 5.9679e+01