Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

rules for using functions as basis vectors

  • To: mathgroup at smc.vnet.net
  • Subject: [mg67110] rules for using functions as basis vectors
  • From: Kenny Stephens <kstephens at hsutx.edu>
  • Date: Fri, 9 Jun 2006 01:09:23 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Thanks for the help but I'm hesitant to alter the attributes of Dot.
Also, it is not the orderless aspect of Dot that gives me my main
difficulty. I do not know how to specify the necessary rules. Here is an
updated version of my code.

(* here are the rules for dot products between the basis elements *) 
{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};

(* here are the relations between derivatives of the basis elements *)
(* and the defining curve from which the basis is derived, i.e., the *)
(* Frenet-Seret relations *)
{Derivative[1][r][u_] := t[u],
 Derivative[1][t][u_] := \[Kappa][u] n[u],
 Derivative[1][n][u_] := \[Tau][u] b[u] - \[Kappa][u] t[u],
 Derivative[1][b][u_] := -\[Tau][u] n[u]};

(* here are the rules for how to handle dot products between the *)
(* basis elements and products *)
{b /: Dot[b[u_], Times[a_, f__]] := Dot[b[u], ExpandAll[Times[a, f]]],
 b /: Dot[Times[a_, f__], b[u_]] := Dot[ExpandAll[Times[a, f]], b[u]]};
{t /: Dot[t[u_], Times[a_, f__]] := Dot[t[u], ExpandAll[Times[a, f]]],
 t /: Dot[Times[a_, f__], t[u_]] := Dot[ExpandAll[Times[a, f]], t[u]]};
{n /: Dot[n[u_], Times[a_, f__]] := Dot[n[u], ExpandAll[Times[a, f]]],
 n /: Dot[Times[a_, f__], n[u_]] := Dot[ExpandAll[Times[a, f]], n[u]]};

(* here are the rules for how to handle dot products between the *)
(* basis elements and products of symbols & basis elements *)
(* I'm unclear why I must have these rules and the previous product *)
(* rules --- shouldn't the following rules be sufficient? *)
(* Also, note that I've included the orderless rules for my basis *)
(* elements *)
{b /: Dot[b[u_], Times[a___, b_[u_]]] := a b[u].b[u],
 b /: Dot[b[u_], Times[a___, t[u_]]] := a b[u].t[u],
 b /: Dot[b[u_], Times[a___, n[u_]]] := a b[u].n[u],
 b /: Dot[Times[a___, b[u_]], b[u_]] := a b[u].b[u],
 b /: Dot[Times[a___, t[u_]], b[u_]] := a t[u].b[u],
 b /: Dot[Times[a___, n[u_]], b[u_]] := a n[u].b[u]};
{t /: Dot[t[u_], Times[a___, b[u_]]] := a t[u].b[u],
 t /: Dot[t[u_], Times[a___, t[u_]]] := a t[u].t[u],
 t /: Dot[t[u_], Times[a___, n[u_]]] := a t[u].n[u],
 t /: Dot[Times[a___, b[u_]], t[u_]] := a b[u].t[u],
 t /: Dot[Times[a___, t[u_]], t[u_]] := a t[u].t[u],
 t /: Dot[Times[a___, n[u_]], t[u_]] := a n[u].t[u]};
{n /: Dot[n[u_], Times[a___, b[u_]]] := a n[u].b[u],
 n /: Dot[n[u_], Times[a___, t[u_]]] := a n[u].t[u],
 n /: Dot[n[u_], Times[a___, n[u_]]] := a n[u].n[u],
 n /: Dot[Times[a___, b[u_]], n[u_]] := a b[u].n[u],
 n /: Dot[Times[a___, t[u_]], n[u_]] := a t[u].n[u],
 n /: Dot[Times[a___, n[u_]], n[u_]] := a n[u].n[u]};

(* here are the rules for how to handle dot products between the *)
(* basis elements and sums *)
{b /: Dot[b[u_], Plus[y_, z_]] := b[u].y + b[u].z,
 b /: Dot[Plus[y_, z_], b[u_]] := y.b[u] + z.b[u]};
{n /: Dot[n[u_], Plus[y_, z_]] := n[u].y + n[u].z,
 n /: Dot[Plus[y_, z_], n[u_]] := y.n[u] + z.n[u]};
{t /: Dot[t[u_], Plus[y_, z_]] := t[u].y + t[u].z,
 t /: Dot[Plus[y_, z_], t[u_]] := y.t[u] + z.t[u].z};

--------------------------------------------------------------------
Now here are the results

(* this tests the rules for dot products between products and single *)
(* basis elements *)
 In:= (2 \[Tau][x] b[x])) . t[x]
Out:= 0 (* correct *)

(* this tests the rules for dot products between sums and single *)
(* basis elements *)
 In:= b[x] . (t[x] - n[x] z \[Tau][x] 
             + y (-t[x] \[Kappa][x] + b[x] \[Tau][x] ) )
Out:= y \[Tau][x] (* correct *)

(* this tests the rules for dot products between sums of products *)
(* of the basis elements *)
 In:= (t[x] - n[x] z \[Tau][x] 
      + y (-t[x] \[Kappa][x] + b[x] \[Tau][x] ) ) . 
     (t[x] - n[x] z \[Tau][x] 
     + y (-t[x] \[Kappa][x] + b[x] \[Tau][x] ) )
Out:= (t[x] - n[x] z \[Tau][x] 
      + y (-t[x] \[Kappa][x] + b[x] \[Tau][x] ) ) . 
     (t[x] - n[x] z \[Tau][x] 
     + y (-t[x] \[Kappa][x] + b[x] \[Tau][x] ) )

This is not simplified at all. I believe the problem is that this really
looks like Dot[ Sum[...], Sum[...] ] and I have no rules for dot
products between sums. And I can't since that places b, n, and t too
deep to work for defining upvalues.

So I guess my problem (and question) is what can I implement to teach
Mathematica how to simplify dot products of sums for my basis elements?


  • Prev by Date: Re: Or in a Select question
  • Next by Date: Re: Re: Two questions (1) Sollve and (2) Precision
  • Previous by thread: Re: rules for using functions as basis vectors
  • Next by thread: Or in a Select question