MathGroup Archive 2003

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

Search the Archive

RE: Perform an assigment

  • To: mathgroup at smc.vnet.net
  • Subject: [mg43893] RE: [mg43865] Perform an assigment
  • From: "David Park" <djmp at earthlink.net>
  • Date: Fri, 10 Oct 2003 03:06:03 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Paulo,

Generally, I would recommend against assigning values to your variables.
Using the Rules that the Solve routine returns is often more convenient. If
you assign values you can no longer use the variables as symbols until you
Clear them.

Nevertheless, the following is how you can do it.

eqns = {2x + 3y == 5, x - y == 2};
sols = Solve[eqns, {x, y}][[1]]
x = x /. sols
y = y /. sols

{x -> 11/5, y -> 1/5}
11/5
1/5

But now see what happens is you try to evaluate the statements again. (Say
you decided you wanted 3 x + 3 y in the first equation.)
Instead, you can use the rules to substitute into expressions on a
controlled basis and continue to use x and y as symbolic variables.

Clear[x, y]
sols = Solve[eqns, {x, y}][[1]]

x^2 + 3x y /. sols
154/25

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/


From: paulocct at uniquindio.edu.co [mailto:paulocct at uniquindio.edu.co]
To: mathgroup at smc.vnet.net

Hi all,
I want to solve a system of equations and to assign the values
calculated to the variables of the system automatically, What should I
do?. What command should I use?

Thanks a lot,

Paulo Carmona
University of Quindio
Colombia




  • Prev by Date: Re: piecewise definition of a function
  • Next by Date: Re: $CommandLine
  • Previous by thread: Re: Perform an assigment
  • Next by thread: Re: Perform an assigment