       Re: rules for using functions as basis vectors

• To: mathgroup at smc.vnet.net
• Subject: [mg67091] Re: rules for using functions as basis vectors
• From: dh <dh at metrohm.ch>
• Date: Fri, 9 Jun 2006 01:07:34 -0400 (EDT)
• References: <e68q2o\$cv7\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Hi Kenny,
Dot does not have the Attribute "Orderless" as you can convince yourself
by: Attributes[Dot]. That means Dot does care about the order of the
arguments! This makes sense because Dot not only multiplies vectors, but
also higher tensors where the order may be important.
There are two ways out. Either you specify your declarations
symmetrically or you set the Orderless attribute of Dot by:
Unprotect[Dot];
SetAttributes[Dot,Orderless]

Daniel

Kenny Stephens wrote:
> I am trying to establish some rules to use a triad of functions as a
> triad of basis vectors (i.e., Frenet-Seret formalism). I have achieved
> most of the desired functionality but I can not get Mathematica to
> properly expand dot products across parantheses. Here is my code.
>
> (* define the tangent vector of the curve r[u] *)
> r /: D[r[u_], u_] := t[u];
>
> (* define the dot product relations between the triad vectors *)
> {t /: t[u_].t[u_] := 1, t /: t[u_].n[u_] := 0, t /: t[u_].b[u_] := 0,
>  n /: n[u_].t[u_] := 0, n /: n[u_].n[u_] := 1, n /: n[u_].b[u_] := 0,
>  b /: b[u_].t[u_] := 0, b /: b[u_].n[u_] := 0, b /: b[u_].b[u_] := 1};
>
> (* define the Frenet-Seret relations *)
> {Derivative[t][u_] := \[Kappa][u] n[u],
>  Derivative[n][u_] := \[Tau][u] b[u] - \[Kappa][u] t[u],
>  Derivative[b][u_] := -\[Tau][u] n[u]};
>
> (* how to distribute the triad vectors across multiplication *)
> {b /: Dot[b[u_], Times[a_, f_]] := Dot[b[u], ExpandAll[Times[a, f]]],
>  t /: Dot[t[u_], Times[a_, f_]] := Dot[t[u], ExpandAll[Times[a, f]]],
>  n /: Dot[n[u_], Times[a_, f_]] := Dot[n[u], ExpandAll[Times[a, f]]]};
>
> (* how to distribute the dot product across additions *)
> {b /: Dot[b[u_], Plus[y_, z_]] :=
>       Dot[b[u], ExpandAll[y]] + Dot[b[u], ExpandAll[z]],
>  n /: Dot[n[u_], Plus[y_, z_]] :=
>       Dot[n[u], ExpandAll[y]] + Dot[n[u], ExpandAll[z]],
>  t /: Dot[t[u_], Plus[y_, z_]] :=
>       Dot[t[u], ExpandAll[y]] + Dot[t[u], ExpandAll[z]]};
>
> (* how to neglect the curvature and torsion from dot products *)
> {b /: Dot[b[u_], \[Tau][u_]] := 0, b /: Dot[\[Tau][u_], b[u_]] := 0,
>  t /: Dot[t[u_], \[Tau][u_]] := 0, t /: Dot[\[Tau][u_], t[u_]] := 0,
>  n /: Dot[n[u_], \[Tau][u_]] := 0, n /: Dot[\[Tau][u_], n[u_]] := 0};
> {b /: Dot[b[u_], \[Kappa][u_]] := 0, b /: Dot[\[Kappa][u_], b[u_]] := 0,
>  t /: Dot[t[u_], \[Kappa][u_]] := 0, t /: Dot[\[Kappa][u_], t[u_]] := 0,
>  n /: Dot[n[u_], \[Kappa][u_]] := 0, n /: Dot[\[Kappa][u_], n[u_]] :=0};
>
> (* how to distribute dot products across multiplication of several *)
> (* terms; this is necessary to avoid exceeding iteration limits *)
> {b /: Dot[b[u_], Times[a_, b[u_], g_[u_]]] := a g[u] b[u].b[u],
>  b /: Dot[b[u_], Times[a_, t[u_], g_[u_]]] := a g[u] b[u].t[u],
>  b /: Dot[b[u_], Times[a_, n[u_], g_[u_]]] := a g[u] b[u].n[u]};
> {t /: Dot[t[u_], Times[a_, b[u_], g_[u_]]] := a g[u] t[u].b[u],
>  t /: Dot[t[u_], Times[a_, t[u_], g_[u_]]] := a g[u] t[u].t[u],
>  t /: Dot[t[u_], Times[a_, n[u_], g_[u_]]] := a g[u] t[u].n[u]};
> {n /: Dot[n[u_], Times[a_, b[u_], g_[u_]]] := a g[u] n[u].b[u],
>  n /: Dot[n[u_], Times[a_, t[u_], g_[u_]]] := a g[u] n[u].t[u],
>  n /: Dot[n[u_], Times[a_, n[u_], g_[u_]]] := a g[u] n[u].n[u]};
>
> Now the following expression works (copied straight from Mathematica):
> \!\(b[u\_1] . \( (t[u\_1] - n[u\_1]\ u\_3\ \[Tau][u\_1]
>                  + u\_2\ \((\(-t[u\_1]\)\ \[Kappa][u\_1]
>                  + b[u\_1]\ \[Tau][u\_1]) \))\) \)
> giving the correct result
> \!\(u\_2\ \[Tau][u\_1]\)
>
> However, exchanging the order of the arguments to the dot product does
> not work (having b[u\_1] on the right side of the dot product instead of
> the left). Mathematica simply returns the input. Furthermore, if one
> dots the argument in parantheses with itself, the input is likewise
> returned.
>
> What am I missing? Any suggestions on how to get this to work would be
> greatly appreciated.
>
> Thanks.
>

```

• Prev by Date: Re: Re: Two questions (1) Sollve and (2) Precision
• Next by Date: Re: Re: Re: Colored Tick Labels?
• Previous by thread: rules for using functions as basis vectors
• Next by thread: rules for using functions as basis vectors