kill(all)$

maxima:fvm : unstructed-grids (Triangles), n.grad(Φ) =∂Φ/∂n,version 1.0
peter.vlasschaert@gmail.com,10/03/2023

load package:

load(lrats)$

find : n.grad(Φ) = n.∇(Φ) =∂(Φ)/∂n
--------------------------------------------

graph : construct with Geogebra version 6.0 (by Peter Vlasschaert).

find : {e1,e2,e3}
--------------------

-----------------------------------------------------------------------------------------------------------------------

dot product : vec(v1).vec(v2) = |vec(v1)|*|vec(v2)|*cos(v1,v2) =vec(v2).vec(v1)
                     → when vec(v1) = unitvector1,vec(v2) = unitvector2
                    vec(v1).vec(v2) =cos(v1,v2)          ,smallest angle between CCW between (v1,v2).
-------------------------------------------------------------------------------------------------------------------------

→ e[z] and n        , ref :angle : α,β ;  α =β

d1:e[z]*n = cos(α);/*ref:angle define*/

→ e[z] and e[s]    , angle  : α +Π/2, because : angle → between(n,e[s])=Π/2 =%pi/2

d2:e[z]*e[s]=cos(α+%pi/2);

rem :general use , "trigexpand"
----------------------------------------

--------------------------------------------------------------

d3:cos(θ1+θ2) =ev(cos(θ1+θ2),trigexpand);

----------------------------------------------------------------

d4:[d1,d2];

define :∇(Φ) 
---------------
→1e) cartesian      axes : unit vectors :{i,j} , 2d 
→2e) e[s] and n,system : unit vectors :{e[s],n} , 2d 

gr1:∇(Φ) ='diff(Φ,x)*i+'diff(Φ,y)*j;
gr2:∇(Φ) ='diff(Φ,n)*n+'diff(Φ,s)*e[s];

→ first step : define {n,e[s],e[z]},cartesian axes.

⇒ e[s] @ right angle to  n ,e[s].n = cos(Π/2)=0,see: figure1

ang1:e[s]=(x[b]-x[a])/Δs*i+(y[b]-y[a])/Δs*j;

ang2:n=((y[b]-y[a])*i)/Δs-((x[b]-x[a])*j)/Δs;

rule : dot product.

rule:[i*i=1,j*j=1,i*j=0,j*i=0];

result: check ,perpenducularity

angu:expand(ang1*ang2);

angu:lratsubst(rule,angu);

you need package : lrats, because: subst can't make simplification : i*j=0;

⇒ e[z] , x[C[N]]=x[C]

ange:e[z]=(x[C]-x[p])/Δz*i+(y[C]-y[p])/Δz*j;

→ second step : projection on diirection e[z] for grad(Φ)

math notation: see: gr2
-------------------
proj       ∇(Φ)  =∇(Φ)*e[z]
       e[z]
two components =(n*('diff(Φ,n)),e[s]*('diff(Φ,s)))

prj:expand(gr2*e[z]);

prj:lratsubst(d4,prj);

→ thrid step : figure find ei,{i=1,2,3}

proj: from ∂Φ/∂n on e[z],direction:

e2:part(rhs(prj),1);

proj: from ∂Φ/∂s on e[z],direction:

rem : -|G,Ni| =e1 ,easy to see : sin function

e1:part(rhs(prj),2);

e3:'diff(Φ,z);

→ fourth step: relation between ,ei ,i=1,2,3

ee:e3=e1+e2;

→fifth step : solve for ('diff(Φ,n,1))

w1:expand(solve(ee,'diff(Φ,n,1)));

to get tan(α) in w1

w1a:lhs(w1[1])=ev(part(rhs(w1[1]),1),trigreduce)+part(rhs(w1[1]),2);

discreet: differential

w2a:args(rhs(w1a));

w2a1:part(w2a[1],1)=(Φ[b]-Φ[a])/Δs;

w2a2:part(w2a[2],1)=(Φ[C]-Φ[p])/Δz;

w2aa:[w2a1,w2a2];

w2a3:lhs(w1[1])=n*∇(Φ);

w2bb:flatten([w2a3,w2aa]);

result : discreet,use w1a,w1[1]

w2cc:subst(w2bb,w1a);

w2dd:subst(w2bb,w1[1]);

sixth step : make change trig function,final result

use: d4

z1:d4;

z1a:solve(z1,[cos(α),sin(α)])[1];

use:w2dd

simp:false$

z2a1:subst(z1a,w2dd);

za2:lhs(w2a3) =rhs(z2a1);

dot product : cos(α) =(n.n)/n.e[z],sin(α) =( -e[s].e[z])/(n.e[z]).

----------------------------------------------------------------------------------------------------------