Vector products: Difference between revisions

Add BQN
(Added solution for Action!)
(Add BQN)
Line 856:
a x (b x c) = (-267, 204, -3)
</pre>
 
=={{header|BQN}}==
The cross product function here multiplies each vector pointwise by the other rotated by one. To align this result with the third index (the one not involved), it's rotated once more at the end. The APL solution <code>1⌽(⊣×1⌽⊢)-⊢×1⌽⊣</code> uses the same idea and works in BQN without modification.
<lang bqn>Dot ← +´∘×
Cross ← 1⊸⌽⊸×{1⌽𝔽˜-𝔽}
Triple ← {𝕊a‿b‿c: a Dot b Cross c}
VTriple ← Cross´
 
a←3‿4‿5
b←4‿3‿5
c←¯5‿¯12‿¯13</lang>
 
Results:
<lang bqn> a Dot b
49
 
a Cross b
⟨ 5 5 ¯7 ⟩
 
Triple a‿b‿c
6
 
VTriple a‿b‿c
⟨ ¯267 204 ¯3 ⟩</lang>
 
=={{header|C}}==
99

edits