user = 0;

x = -6:.01:4;
[y, user] = func_e04ab(x, user);

plot(x,y)
title('f(x)=x^{2} + 3x - 5','FontAngle','Italic')
xlabel('x')
ylabel('y','Rotation',0)

e1 = 0;
e2 = 0;
a = -6;  % lower bound
b = 4;   % upper bound
maxcal = nag_int(30);

% find minimum
[e1Out, e2Out, aOut, bOut, maxcalOut, x, f, user, ifail] = ...
    e04ab('func_e04ab', e1, e2, a, b, maxcal)

mytext = sprintf('Minimum (%g,%g) in [%g,%g]',x, f, a, b);
text(-3,10,mytext)

% find maximum, i.e minimum of -f(x)
[e1Out, e2Out, aOut, bOut, maxcalOut, x, f, user, ifail] = ...
    e04ab('func_e04ab_neg', e1, e2, a, b, maxcal)

% note we negate f
mytext = sprintf('Maximum (%g,%g) in [%g,%g]',x, f, a, b);
text(-3,12,mytext)