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


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

Re: [newb] simple equation substitutions

From p-crossbow <goramedforsiktigt@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: [newb] simple equation substitutions
Date 2012-11-02 05:11 +0000
Message-ID <k6vkm7$6il$1@smc.vnet.net> (permalink)
References <k6t7qk$1mi$1@smc.vnet.net>
Organization Time-Warner Telecom

Show all headers | View raw


You would have to use Solve[%,{x,y}] to get the answer you're looking for. My best understanding of this is that Mathematica sees a system of equations with two unknowns - x & y despite the fact that the solution for x is trivial. As such, Solve[] requires both unknowns specified as solve variables in order to return a result that isn't full dimensional.

When you know the value for a variable, as in the case above, it is simpler if you perform a substitution rather than creating another equation for Solve[] to wrestle with.

{y==x+2}/.{x->7}
Solve[%, y]

If you would rather post-process your equations to perform this substitution, one way to do this could be:

eqns={y==x+2,x==7};
eqns/.(Cases[eqns,_Symbol==_Integer]/.{(u_Symbol==v_Integer)->(u->v})

I've assumed above that the RHS is always an integer in my pattern, but this can be adjusted "to taste". I'm sure there are more elegant ways of doing this, and perhaps some of the fine people here can help there.

Le jeudi 1 novembre 2012 00:21:48 UTC-7, Neal Becker a =E9crit :
> {y == x + 2, x == 7}
>
>
>
> Solve[%, y]
>
>
>
> -> {}
>
>
>
> What I expected to happen is have x->7 applied to y == x+2.
>
>
>
> My real plan is to develop a list of (a lot more complicated) expressions that will have repeated substitutions applied.
>
>
>
> Why didn't the above work and/or what should I do instead?

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


Thread

[newb] simple equation substitutions Neal Becker <ndbecker2@gmail.com> - 2012-11-01 07:19 +0000
  Re: [newb] simple equation substitutions "Nasser M. Abbasi" <nma@12000.org> - 2012-11-02 04:45 +0000
  Re: [newb] simple equation substitutions Peter Breitfeld <phbrf@t-online.de> - 2012-11-02 05:11 +0000
  Re: [newb] simple equation substitutions p-crossbow <goramedforsiktigt@gmail.com> - 2012-11-02 05:11 +0000

csiph-web