## Ejemplo: z³+2z(x+y)²+exp(z-1)-4=0

### Definimos la función y compromabos las hipótesis del TFI

F(x,y,z):= z^3+2*(x+y)^2*z+exp(z-1)-4;
a:0$ b:-1$c:1$

F(a,b,c);

diff(F(x,y,z),z);
ev(%,x=a,y=b,z=c);

### Calculamos las primeras derivadas

depends(z,[x,y]);

#### Calculamos zx

eq1:diff(F(x,y,z),x);

solve(eq1,'diff(z,x,1));
zx:rhs(%[1]);
vzx:ev(%,x=a,y=b,z=c);

#### Calculamos zy

eq2:diff(F(x,y,z),y);

solve(eq2,'diff(z,y,1));
zy:rhs(%[1]);
vzy:ev(%,x=a,y=b,z=c);

### Calculamos las segundas derivadas

#### Calculando zxx

zxx1:diff(F(x,y,z),x,2);

/* Método 1*/
subst(['diff(z,y,1)=zy,'diff(z,x,1)=zx, 'diff(z,x,2)=zxx],   zxx1);
ev(%, x=a,y=b,z=c);
solve(%,zxx);

/*Método general */
eqzxx:solve(zxx1,'diff(z,x,2));

/* calculando zxx  el general */
subst(['diff(z,y,1)=zy,'diff(z,x,1)=zx],eqzxx);
rhs(%[1])$
vzxx: ev(%, x=a,y=b,z=c);

/* calculando zxx directamente en el punto (a,b,c) */
subst(['diff(z,y,1)=zy,'diff(z,x,1)=zx,x=a,y=b,z=c],rhs(eqzxx[1]));
vzxx:subst(['diff(z,y,1)=vzy,'diff(z,x,1)=vzx,x=a,y=b,z=c],rhs(eqzxx[1]));

#### Calculando zyy

zyy1:diff(F(x,y,z),y,2);

subst(['diff(z,y,1)=zy,'diff(z,x,1)=zx, 'diff(z,y,2)=zyy],   zyy1);
ev(%, x=a,y=b,z=c);
solve(%,zyy);

eqzyy:solve(diff(F(x,y,z),y,2),'diff(z,y,2));

/* calculando zyy  el general */
subst(['diff(z,y,1)=zy,'diff(z,x,1)=zx],eqzyy);
rhs(%[1])$
vzyy: ev(%, x=a,y=b,z=c);

/* calculando zyy en el punto (a,b,c) */
subst(['diff(z,y,1)=vzy,'diff(z,x,1)=vzx],eqzyy);
vzyy:subst(['diff(z,y,1)=vzy,'diff(z,x,1)=vzx,x=a,y=b,z=c],rhs(eqzyy[1]));

#### Calculando zxy

zxy1:diff(F(x,y,z),x,1,y,1);

subst(['diff(z,y,1)=zy,'diff(z,x,1)=zx,'diff(z,x,1,y,1)=zxy],   zxy1);

ev(%, x=a,y=b,z=c);
solve(%,zxy);

eqzxy:solve(diff(F(x,y,z),x,1,y,1),'diff(z,x,1,y,1));

subst(['diff(z,y,1)=zy,'diff(z,x,1)=zx],eqzxy);
rhs(%[1])$
vzxy: ev(%, x=a,y=b,z=c);

/* calculando zyy en el punto (a,b,c) */
subst(['diff(z,y,1)=vzy,'diff(z,x,1)=vzx],eqzxy);

vzyy:subst(['diff(z,y,1)=vzy,'diff(z,x,1)=vzx,x=a,y=b,z=c],rhs(eqzxy[1]));

/* Calculando el polinomio de Taylor */;

Dz: matrix( [zx,zy] );

vDz:ev(Dz, x=a,y=b,z=c);

D2z: matrix(
 [zxx,zxy], 
 [zxy,zyy]
);

vD2z:ev(D2z,x=a,y=b,z=c,zxx=vzxx,zyy=vzyy,zxy=vzxy);

c + vDz.[(x-a),(y-b)]+ [(x-a),(y-b)].(1/2*vD2z).[(x-a),(y-b)];

### Derivando las expresiones del Teorema

kill(all)$
F(x,y,z):= z^3+2*(x+y)^2*z+exp(z-1)-4;
a:0$ b:-1$c:1$

define(zx(x,y),-diff(F(x,y,z),x)/diff(F(x,y,z),z));
define(zy(x,y),-diff(F(x,y,z),y)/diff(F(x,y,z),z));

vzx:ev(zx(x,y),x=a,y=b,z=c );
vzy:ev(zy(x,y),x=a,y=b,z=c );

depends(z,[x,y]);

dzxx:diff(zx(x,y),x);
subst(['diff(z,x,1)=zx],dzxx);
ev(%, x=a,y=b,z=c,zx=vzx);

dzyy:diff(zy(x,y),y)$
subst(['diff(z,y,1)=zy],dzyy);
ev(%, x=a,y=b,z=c,zy=vzy);

dzxy:diff(zy(x,y),x)$
subst(['diff(z,y,1)=zy,'diff(z,x,1)=zx],dzxy);
ev(%, x=a,y=b,z=c,zx=vzx,zy=vzy);