Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #13448

Re: Differencing two equations

From Bob Hanlon <hanlonr357@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Differencing two equations
Date 2013-02-11 09:36 +0000
Message-ID <kfae39$m53$1@smc.vnet.net> (permalink)
References <20130210082414.C3A5F6937@smc.vnet.net>
Organization Time-Warner Telecom

Show all headers | View raw


eqnOperate[eqn1_, eqn2_, f_] :=
  Equal @@ f @@ {List @@ eqn1, List @@ eqn2};


eqnOperate[a == r, b == s, Subtract]

a - b == r - s


eqnOperate[a == r, b == s, Plus]

a + b == r + s


eqnOperate[a == r, b == s, Times]

a b == r s


eqnOperate[a == r, b == s, Divide]

a/b == r/s


eqnOperate[a == r, b == s, Power[#1, #2] &]

a^b == r^s


Bob Hanlon


On Sun, Feb 10, 2013 at 3:24 AM,  <g.c.b.at.home@gmail.com> wrote:
> I'm brand new to Mathematica, so I apologize for the naive questions...
>
> I'm trying to figure out how to difference two equations.  Basically if I have:
> a==r
> b==s
>
> I'd like to get:
> a-b == r-s
>
> What I'm getting is more like (a==r) - (b==s).  I'm not sure how that's a useful result, but is there a function to do what I'm looking for?
>
> A quick search of the archives seem to bring up ways of doing this from using transformation rules to swap heads to unlocking the Equals operator and hacking its behavior.  I'd like to avoid doing that kind of rewiring for a simple operation, and I'd like to keep the syntax clean.
>
> The Core Language documentation makes a big point of how everything is basically a list with different heads.  In this case, what I'm trying to do would work if it were treated as a list ({a,b}-{r,s} returns {a-b,r-s}) but doesn't work under Equal.
>
> Thanks for any suggestions.
>

Back to comp.soft-sys.math.mathematica | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Re: Differencing two equations Bob Hanlon <hanlonr357@gmail.com> - 2013-02-11 09:36 +0000
  Re: Differencing two equations nma%12000.org@gtempaccount.com - 2013-08-04 09:15 +0000
  Re: Differencing two equations nma%12000.org@gtempaccount.com - 2013-08-04 09:16 +0000

csiph-web