MathGroup Archive 2010

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

Search the Archive

Why do these not work?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg109697] Why do these not work?
  • From: "S. B. Gray" <stevebg at ROADRUNNER.COM>
  • Date: Wed, 12 May 2010 07:34:22 -0400 (EDT)
  • Reply-to: stevebg at ROADRUNNER.COM

There is something about Mathematica which does not allow the first two calls to 
work, and I don't know why. Can anyone give me some guidance?

First, do I need all these things in the Module and is there a shorter 
way to "localize" them?

plane3[p1_,p2_,p3_] :=
  Module[{x1,y1,z1, x2,y2,z2, x3,y3,z3, iden},

   {x1, y1, z1} = p1;
   {x2, y2, z2} = p2;
   {x3, y3, z3} = p3;

   iden = 1/Det[{{x1,y1,z1},{x2,y2,z2},{x3,y3,z3}}];
    (* Or 1/Det[{p1,p2,p3}] *)

    aa = iden*Det[{{ 1, y1, z1},{ 1, y2, z2},{ 1, y3, z3}}];
    bb = iden*Det[{{x1,  1, z1},{x2,  1, z2},{x3,  1, z3}}];
    cc = iden*Det[{{x1, y1,  1},{x2, y2,  1},{x3, y3,  1}}];
    Return[{aa, bb, cc}];     (* Plane: aa*x + bb*y + cc*z = 1 *)
   ]

This ReplaceAll gives the numeric answer I want:
plane3[{x1,y1,z1},{x2,y2,z2},{x3,y3,z3}] /.
  {x1 -> 1, y1 -> 0, z1 -> 0,
   x2 -> 0, y2 -> 1, z2 -> 0,
   x3 -> 0, y3 -> 0, z3 -> 1}
{1,1,1}

This ReplaceAll does not work at all:
plane3[q1,q2,q3]/.{q1->{1,0,0},q2->{0,1,0},q3->{0,0,1}}

This ReplaceAll gives a symbolic answer that I do not want:
q1={x1,y1,z1}; q2={x2,y2,z2}; q3={x3,y3,z3};
plane3[q1,q2,q3]/.{q1->{1,0,0},q2->{0,1,0},q3->{0,0,1}}

What is the rule? I note in ReplaceAll x/.{{x->1},{x->3},{x->7}},
but I don't want one at a time.

Thank you for any tips.
Steve Gray


  • Prev by Date: Re: How to write reports and books in Mathematica
  • Next by Date: Re: 2D plots of data points
  • Previous by thread: Re: Trying to remove item from list of filenames
  • Next by thread: Re: Why do these not work?