:

## Dot product of real vectors

Maple 15

The "." notation for the dot product of Vectors is very convenient and intuitive.  For example:

> <1,2,3> . <1,1,1>;

6

One sometimes annoying feature of it, however, is that by default Maple is using a dot product (suitable for Vectors with complex scalars) that is conjugate-linear in the first argument.  But let's say you will only be working with real scalars.  There's no problem if your Vectors have numeric entries, but if there are symbolic variables you'll see results such as this:

> <a, b, c> . <d, e, f>;

You don't want to see those complex conjugates.  How to avoid them?  You could use the DotProduct command in LinearAlgebra with the option conjugate=false, but it's a lot more characters to type.  But here's a simple way to fix the problem.  I'll use Maple's overload facility to redefine `.` in the case of two Vectors (this operator is also used for other purposes, which we don't want to interfere with).  Actually there are two cases for `.` with two Vectors:  DotProduct when the Vectors have the same orientation and Multiply (which, again, we don't want to interfere with) when they don't.

`> realdot:= module() option package; export `.`;`.`:= proc(a::Vector,b::Vector) option overload;      if VectorOptions(a,'orientation') = VectorOptions(b,'orientation') then          LinearAlgebra:-DotProduct(a,b,conjugate=false)      else LinearAlgebra:-Multiply(a,b)      end if      end proc;end module;`

This package could be saved in a repository that is in your libname. You load it using with.

`> with(realdot):`

And now:

`> <a,b,c> . <d,e,f>;`

﻿