kill(all)$

How to construct : z=f(x,y), tangent plane,tangent line,version 1.0,part1.
peter.vlasschaert@gmail.com, 20/03/2020.

2d version  : y =f(x)  , part   1
3d version  : z=f(x,y), part   2 

=>  curve 

y = f1(x) = x^2
==========

p1: y = f1(x);

p1a:y = x^2;

p1b:wxplot2d([rhs(p1a)],[x,-2,2]);

tangent line to the curve

1e) derivative = m
----------------

p2:"  f1'(x)  " = diff(rhs(p1a),x);

2e) derivative @ x=x0= 1
------------------------------

p2a:"  f1'(x0)  " =at(rhs(p2),x=x0);

p2b:subst([x0 = 1],p2a);

3e) tangentline @ x=x0= 1
--------------------------------

p2c:y-y0 = rhs(p2a)*(x-x0);

ref :y-y0=f1'(x0)*(x-x0)

p2c1:subst([x0=1],p2c);

p2c2:y0=subst([x=1],rhs(p1a));

p2c3:subst([p2c2],p2c1);

p2c4:solve(p2c3,y)[1];

p2d:wxplot2d([rhs(p1a),rhs(p2c4)],[x,-2,2]);

normal line to the curve,  m' = -1/m

p3: y-y0 = -1/rhs(p2a)*(x-x0);

ref :y-y0=-1/f1'(x0)*(x-x0)

p3a:subst([x0=1],p3);

p3b:y0=subst([x=1],rhs(p1a));

p3c:subst([p3b],p3a);

p3d:solve(p3c,y)[1];

axis : 

p3e:wxplot2d([rhs(p1a),rhs(p2c4),rhs(p3d)],[x,-2,2],[y,-2,2],
    [yx_ratio,1])$

blue   :curve           f(x) = (x^2 )
red    :tangent line  (2*x-1)
green:normal line    -(x-3)/2
" theoretical aspect  = "
m = f'(x)  @ x=x0
general equation  :    y=f(x)
tangent line          :   y-y0 =m*(x-x0)
normal line          :    y-y0 =-1/m*(x-x0)

tangent line: @x=x0
========

p4a:y-y0 = at(diff(f(x),x),x=x0)*(x-x0);

normal  line:  @x=x0
=========

p4b:y-y0 = -1/at(diff(f(x),x),x=x0)*(x-x0);