kill(all)$

maxima : programming , my dot product (with use infix operator ="°"),version 1.0a,corrected
peter.vlasschaert@gmail.com,16/02/2023

maxima :my  dot product computation definition,version 1.0.
---------------------------------------------------------------------------------
→  use : unit vectors ,e[i] i=1,2,3

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,inside list
-------------------------------------

→ ≠ if constructs.

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

[s1:0,s2:0,s3:0];/*setting : initial values =0*/

→ position in list : p1c

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

print(" value :s2 =",s2);

→ no answer 

find :e[.] inside list. {. =1,2,3}
--------------------------

→ if & or (= logical operator ,and ,or,xor,nand)

 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;

construct : dot product. (with : infix operator ( = °))
======================================

1e) find :e[i],i=1,2,3
---------------------------

make definition : ecoefind 

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 : use grind
--------------------

grind(ecoeffind)$

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

example :

mx1:ecoeffind(p1c1);

mx2:ecoeffind(p1b1);

find :e[k] → p1c1[sv]

2e) use infix operator (°) ,for replacement ( = orginal dot product)
--------------------------------------------------------------------------------------

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   
                           );

check : relation with infix operator ( = dot product)
=====================================

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 the infix operator

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

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