kill(all)$

maxima : operator construct 'curl (vector)',vector analysis,(prefix & infix) 'version 1.0'
peter.vlasschaert@gmail.com,10/10/2021

mathematics : notation lhs :∇x(vector(a)),we will use ' infix notation '  x → *
==========================================================
final :check result against  'load(vect)',example

first part : rhs()
===========

step 1: variable construct   xi ,i=1,2,3
-------------------------------------------------

p1: makelist(concat(x,i),i,1,3);

rem; {x1 → x,x2→ y,x3→z} ,cartesian coordinate system.

step 2 : unit vector      ei,i=1,2,3
------------------------------------------

p1a:makelist(concat(e,i),i,1,3);

rem; {e1→ i,e2→ j,e3→k} ,cartesian coordinate system.

step  3:differential operator construct
--------------------------------------------------
rem :φ differentation wih respect to x 

part 1:
=====

f[x](φ):='diff(φ,x);

f[p1[1]](φ);

part 2:
=====

prefix("f[x]");

test : φ :x^2

p2:f[p1[1]] (x1^2);

listofvars(%);

f[p1[1]](x1^2)= ev(p2,nouns);

part 3: use matrix
=====

p2a:makelist(concat(φ,ii),ii,1,3);

p2b:ff[p1[1]](p2a[1]);

ff[x](φ):='diff(φ,x);

prefix("ff[x]");

step  3: construct matix 
--------------------------------
use : menu : matrix  3 by 3  (matrix  3 rows  & 3 columns)

MENU →Matrix → Generate Matrix  
rem :name :p3 Array :aa

p3: genmatrix(aa, 3, 3);

→ first row :matrix(aa)

p3a:makelist(aa[1,ii]=p1a[ii],ii,1,3);

 p3a1:subst(p3a,p3);

→ second row matrix(aa), use p3a1

p3a2:makelist(aa[2,ii]=ff[p1[ii]] ,ii,1,3);

p3a21:subst(p3a2,p3a1);

→ thrid row Gi (x1,x2,x3),use p3a21

p3a3:makelist(aa[3,ii]=concat(G,ii)(p1[1],p1[2],p1[3]) ,ii,1,3);

G:makelist(rhs(p3a3[ii]),ii,1,length(p3a3));

p3a31:subst(p3a3,p3a21);

step 4: computation :determinant
---------------------------------------------

p4a:determinant(p3a31);

p4a1:args(p4a);

sign of  cofactor : (+,-,+) : from unit  vector ei, i=1,2,3

p4a2:[e1,-e2,e3];

p4a3:p4a1/p4a2;

step 5: final result.
--------------------------

p5a0:part(p4a3,1,1);
p5a1:part(p4a3,1,2,1);
p5a2:part(p4a3[1],2,0);

p5b01:part(p4a3[1],1,1);
p5b02:part(p4a3[1],1,2);
p5b021:args(part(p4a3[1],1,2))[2];/* args :result in a list */

after :args can put  function : flatten

p5b022:subst([φ=part(p4a3[1],1,1)],args(part(p4a3[1],1,2))[2]);

p5b1:part(p4a3[1],2,1,1);
p5b2:part(p4a3[1],2,1,2);
p5b21:args(part(p4a3[1],2,1,2))[2];/* args :result in a list */

p5b22:subst([φ=part(p4a3[1],2,1,1)],args(part(p4a3[1],2,1,2))[2]);

→first element : vector 'e1'

p5c1:[subst([φ=part(p4a3[1],1,1)],args(part(p4a3[1],1,2))[2])-subst([φ=part(p4a3[1],2,1,1)],args(part(p4a3[1],2,1,2))[2]),0,0];

use :p4a2

result :first vector element
=====================

p5c2:p4a2*p5c1;

→ first element ,second element ,thrid element

insert  p4a3[1] → p4a3[2]→p4a3[3]

combination :all elements

p6a:makelist(subst([φ=part(p4a3[ii],1,1)],args(part(p4a3[ii],1,2))[2])-subst([φ=part(p4a3[ii],2,1,1)],args(part(p4a3[ii],2,1,2))[2]),ii,1,3);

result :all vector element
=====================

p6b:p4a2*p6a;

see :result : substution  see above 'p4a2,p4a3', properbaly otherways to do substitution.('use of args ).

second part :final result
===================

rem : use 'infix' operator , operation definition between  two terms .

lhs : textual representatin.:curl(G), G=vector (G1,G2,G3)

"∇x[G1(x1,x2,x3),G2(x1,x2,x3),G3(x1,x2,x3)] = ";p6b;

lhs: with use of infix operator

infix("°");

∇°G :=ev( ''p6b/p1a,nouns);

G;

∇°G;

check : load(vect)

aa) load packages
----------------------------

load(vect)$

bb)  problem scale factors ,extra substitution
-------------------------------------------------------------

scalefactor([p1,x1,x2,x3])$

p7:express(curl(G));

p7a:[x=x1,y=x2,z=x3];/*extra substitution */

cc) final result curl of a vector.
----------------------------------------

p7b:subst(p7a,p7);

check : is ' between build in curl and operator definition for curl '
========

p7c:is(∇°G=p7b);

example : curl(G)
==============

G1(x1,x2,x3):=2*x1^3+5*x3^2+x2;
G2(x1,x2,x3):=2*x2+8*x1^3;
G3(x1,x2,x3):=3*x3^6+x2+x1;

∇°G;

p8:p7b;

p8a:ev(p8,nouns);

check :example 

is(∇°G=p8a);

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