MathGroup Archive 2009

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

Search the Archive

Re: How to feed a list of xy pairs into Solve to output

  • To: mathgroup at smc.vnet.net
  • Subject: [mg101213] Re: [mg101149] How to feed a list of xy pairs into Solve to output
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Fri, 26 Jun 2009 06:55:48 -0400 (EDT)
  • Reply-to: hanlonr at cox.net

list = {{1, 2}, {3, 1}, {5, 4}, {6, 3}, {2, 5}};

{#[[1]], #[[2]], 
   z /.
    Solve[6*#[[1]] + 4*#[[2]] + z == 1, z][[1]]} & /@
 list

{{1, 2, -13}, {3, 1, -21}, {5, 4, -45}, {6, 3, -47}, {2, 5, -31}}

Flatten[{##, z /.
     Solve[{6, 4}.## + z == 1, z][[1]]}] & /@
 list

{{1, 2, -13}, {3, 1, -21}, {5, 4, -45}, {6, 3, -47}, {2, 5, -31}}

{x, y, z} /. {Reduce[{6 x + 4 y + z == 1, 0 < x < 7, 0 < y < 6}, z, 
    Integers] // ToRules}

{{1, 1, -9}, {1, 2, -13}, {1, 3, -17}, {1, 4, -21}, {1, 5, -25}, 
   {2, 1, -15}, {2, 2, -19}, {2, 3, -23}, {2, 4, -27}, {2, 5, -31}, 
   {3, 1, -21}, {3, 2, -25}, {3, 3, -29}, {3, 4, -33}, {3, 5, -37}, 
   {4, 1, -27}, {4, 2, -31}, {4, 3, -35}, {4, 4, -39}, {4, 5, -43}, 
   {5, 1, -33}, {5, 2, -37}, {5, 3, -41}, {5, 4, -45}, {5, 5, -49}, 
   {6, 1, -39}, {6, 2, -43}, {6, 3, -47}, {6, 4, -51}, {6, 5, -55}}


Bob Hanlon

---- Bill <WDWNORWALK at aol.com> wrote: 

=============
Hi:

Let's say that I have a list of xy coordinate pairs:

list= {{1,2}},{3,1},{5,4},{6,3},{2,5}}.

Now I'd like to find xyz triplets using Solve for the equation 6*x + 4*y + z == 1.

xyz results:  {{1,2,-13}},{3,1,-21},{5,4,-45},{6,3,-47},{2,5,-31}}. (I used Solve 5 times.)


Question: How do I code that into Mathematica for a "one shot output?" (Use Solve once.)



Thanks,

Bill


Mathematica 6.0.1 using Win XP on a pc.



  • Prev by Date: Re: Wolfram | Alpha: Acres per square mile? (oddities)
  • Next by Date: Re: Plot with x value in Log
  • Previous by thread: Re: Eigenvalue bug in Mathematica 7.0.0
  • Next by thread: Re: How to feed a list of xy pairs into Solve to output xyz