Re: Tangentes et dérivées partielles

Variation sur le même thème :
Maurice
- Code: Tout sélectionner
import graph3;
size(12cm,0);
currentprojection=orthographic(
camera=(6.70544201648284,-0.775280645147703,1.90994169441184),
up=(-0.00381197716192466,0.00208518736562723,0.0142295375229004),
target=(-8.88178419700125e-16,-8.88178419700125e-16,-8.88178419700125e-16),
zoom=1);
//currentprojection=orthographic(1,2,1);
//currentlight=(1,-1,0.5);
pair a=(-2.5,-2);
pair b=(2.5,2);
//Definition de la surface
real f(pair z) {
real r=z.x^2+z.y^2;
if (r!=0) return z.x*z.y/r;
else return 0;
}
surface s=surface(f,a,b,25,25,Spline);
//Intersection avec y=cy
real cy=0;
real x1(real t) {return t;}
real y1(real t) {return cy;}
real z1(real t) {pair z=(t,cy); return f(z);}
path3 inter1=graph(x1,y1,z1,a.x,b.x);
//Intersection avec x=cx
real cx=0;
real x2(real t) {return cx;}
real y2(real t) {return t;}
real z2(real t) {pair z=(cx,t); return f(z);}
path3 inter2=graph(x2,y2,z2,a.y,b.y);
//intersection des deux chemins
triple inter=intersectionpoint(inter1, inter2);
//Derivées partielles
real dx=0.1^10, dy=dx;
pair interplusdx=(inter.x+dx,inter.y);
//pair interx=project(inter,Z);
pair interx=(inter.x,inter.y);
real partialx=(f(interplusdx)-f(interx))/dx;
path3 tgx=inter--(inter.x+1,inter.y,inter.z+partialx);
pair interplusdy=(inter.x,inter.y+dy);
pair intery=(inter.x,inter.y);
real partialy=(f(interplusdy)-f(intery))/dy;
real nor=sqrt(inter.x^2+(inter.y+1)^2+(inter.z+partialy)^2);
path3 tgy=inter--(inter.x,inter.y+1,inter.z+partialy)/nor;
// Eléments graphiques
draw(s,lightgray+opacity(0.8),lightgray+thick());
draw(inter1,blue);
draw(inter2,red);
dot(inter, 5bp+green);
axes3("$x$", "$y$", "$z$",
min=(a.x,a.y,0),
max=(b.x,b.y,1.25),
Arrow3);
draw(tgx,green,Arrow3);
draw(tgy,green,Arrow3);
Maurice