/* Ex. 1a -- analytical maximum.*/
f:x/(a+b*x+c*x^2);

diff(f,x);

ratsimp(%);

solve(num(%)=0,x);

/*  1b  */
[diff(exp(-x^2-4*y^2+4*x-4),x),diff(exp(-x^2-4*y^2+4*x-4),y)];

solve(%,[x,y]); /* Note this is the same as solving [4-2x=0,-8y=0] */;

/* 1c */
[diff(sqrt(17*z^2+%pi*y^2+sqrt(2)*x^2+exp(1)*w^2+1),w),
 diff(sqrt(17*z^2+%pi*y^2+sqrt(2)*x^2+exp(1)*w^2+1),x),
 diff(sqrt(17*z^2+%pi*y^2+sqrt(2)*x^2+exp(1)*w^2+1),y),
 diff(sqrt(17*z^2+%pi*y^2+sqrt(2)*x^2+exp(1)*w^2+1),z)];

/* Note all the denomenators are positive for real w,x,y,z, thus we see the numerators give... */
solve(%);

/* Ex 2 */
f:x+y;

g:x^2+y^2-4;

[diff(f,x)=L*diff(g,x),diff(f,y)=L*diff(g,y)];

solve(%,[x,y]);

g,%; /* this substites the above into g */;

solve(%,L);

%o12,%o14[1];

%o12,%o14[2];

/* ****** BONUS ****** */
[x=r*cos(z), y=r*sin(z)];

%o10,%;

trigreduce(%);

/* The constraint implies r=2. Thus it remains to optimize ... */
x+y,%o17;

%,[r=2];

solve(diff(%,z),z);

/* Which implies the same answer obtained above. %/