Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1998
*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 1998

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

Search the Archive

Re: new user help

  • To: mathgroup at smc.vnet.net
  • Subject: [mg13406] Re: new user help
  • From: phbrf at t-online.de (Peter Breitfeld)
  • Date: Thu, 23 Jul 1998 03:32:50 -0400
  • Organization: das ist ein weites Feld ...
  • References: <6okkvj$1md@smc.vnet.net> <6ous3s$jh3@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Allan Hayes <hay at haystack.demon.cc.uk> schrieb/wrote:
: 
: John M. Dlugosz wrote in message <6okkvj$1md at smc.vnet.net>...
: >I'm lost.  I just don't know how to get started...
: >
: >The excersize I've chosen for myself is to start with
: >
: > x^2+y^2+4x-6y+4==0
: >
: >and manipulate it into the form (x-h)^2+(y-k)^2==r^2
: >
: >So... how do I "manipulate" the equasion?  The functions like Expand,
: >Factor, etc. don't help much.  I my calculator (an HP48) I can point to
: >specific subexpressions and apply operations to them, like factor,
: >distribute, changing forms, etc.
: >
: >How do I collect the x's together in parens, the y's in parens, and
: >complete the squares?  Doing it on paper defeats the point!  I want to
: >learn how to "do math" using this tool.  That's more than just asking
: >"OK, what's X?".  It means manipulating things and arranging them,
: >getting to know how the symbols all fit together.
: >
: >--John
: 

Try to use a replacement-rule:

eq = x^2+y^2+4x-6y+4==0

quadRule = { x_^2 + x_       -> (x+1/2)^2-1/4,                [1]
             x_^2 + b_ x_    -> (x+b/2)^2-b^2/4,
             a_ x^2 + x_     -> a(x-1/(2a))^2-1/(4a),
             a_ x_^2 + b_ x_ ->a(x+b/(2a))^2-b^2/(4a) }

Then do

In:  qf=eq //. quadRule                                 [2] Out: -9 +
(2+x)^2 +(-3+y)^2==0

In: (#-qf[[1,1]])& /@ qf                                [3] Out: (2+x)^2
+ (-3+y)^2 == 9

[1] To make this work in the general case, you have to give all the
    four  rules, because the FullForm of x^2+4x doesn't match 
    a_ x_^2 + b_ x_ because there is no "a" etc. 

[2] If you don't use ReplaceRepeated here, you only get the x-term in
    quadratic form
    
[3] Mathematica orders term always with numbers in the first place, so
    qf[[1,1] represents the "-9" in this example. (#-qf[[1]])& is a pure
    function, which subtracts qf[[1]] from the given expression. Here I
    map this function on the equation (via /@) so the "-9" will be sub-
    tracted from both sides of the equation qf.
    
I don't think there is a simple way to write the 9 as 3^2, because
Mathematica will simplify 3^2 to 9 immediately.    

es gruesst
      Peter

-- 
=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=
  P e t e r  B r e i t f e l d                    eMail:
phbrf at t-online.de
  Kreuzgasse 4, 88348 Saulgau, Germany            PGP public key
available
=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=


  • Prev by Date: Read PGM files
  • Next by Date: Re: Re: How to declare Integers?
  • Previous by thread: Re: new user help
  • Next by thread: Re: new user help