kill(all)$

maxima :fvm ,appendix my dot product (with use infix operator ="°"),version 1.0
peter.vlasschaert@gmail.com,22/12/2022

maxima :my  dot product computation definition,version 1.0.
---------------------------------------------------------------------------------

1e) g1°g2 , infix operator computation
2e) ecoeffind :definition

p1a:e[1]·(at('diff(Φ,x,1),x=w));
p1b:(at('diff(Φ,x,1),x=w))*d*e[1];
p1c:t(x)*Δy*h*a[1]*e[2];

p1a1:args(p1a);

p1a1x:length(p1a1);

p1b1:args(p1b);

p1b1x:length(p1b1);

p1c1:args(p1c);

p1c1x:length(p1c1);

find :e[k],k = 1,2,3
-------------------------

p2a:makelist(e[k],k,[1,2,3]);

 for i:1 thru p1c1x do(
 if e[1] =p1c1[i]  then s1:i,
 if e[2] =p1c1[i]  then s2:i,   
 if e[3] =p1c1[i]  then s3:i
);
p2b:[s1,s2,s3];
p2c:apply("+",p2b);

find :e[.] inside list.
--------------------------

 for i:1 thru p1c1x do(
 if e[1] =p1c1[i]  or e[2] =p1c1[i]  or e[3] =p1c1[i]   then  s:i
 );
p2b1:s$

ecoeffind(sf1):=block([], 
 ll1:length(sf1),
 ll2:makelist(i,i,1,ll1),     
 for i:1 thru ll1 do(
 if e[1] =sf1[i]  or e[2] =sf1[i]  or e[3] =sf1[i]   then  sv:i
 ),
 sx1:delete(sv,ll2),
 sx2:makelist(sf1[fx],fx,sx1),
 sx3:apply("*", sx2),return([sx3,sf1[sv]])  
                       )$       
    
    

optimized code 
--------------------

grind(ecoeffind)$

rem : sv need find e[k],k ,

mx1:ecoeffind(p1c1);

mx2:ecoeffind(p1b1);

find :e[k] → p1c1[sv]

infix("°");
 "°"(aa,bb) :=(
  if is(part(aa,1) =part(bb,1) ) and  is(part(aa,0) =part(bb,0)) then 1
     else 
  if   part(aa,0) ≠ part(bb,0)  then aa*bb else 0   
                           );

example :only with infix operator = "°"
--------------------------------------------------

in1:print ( "e[1]°e[2] = ",e[1]°e[2]);
in2:print ( "e[2]°e[2] = ",e[2]°e[2]);
in3:print ( "a[2]°b[2] = ",a[2]°b[2]);
in3:print ( "a[2]°e[2] = ",a[2]°e[2]);

example : ecoeffind &infx operator  = "°"
-----------------------------------------------------

mx3:mx1[1]*mx1[2]°mx2[2]*mx2[2];

mx3a:mx1[2]*mx1[1]°mx2[2]*mx2[2];

mx4:mx2[1]*mx2[2]°mx2[2]*mx2[1];

→ coef :

mx5:mx1*mx2; /* product of two list */

→ e product ,use infix operator

mx6:mx1[2]°mx2[2];/*infix "°"*/

final result: same result mx3

mx7:mx5[1]*mx6;

is(mx7=mx3);