AW: How to extract a solution from Mathematica's answer to "Solve"
- To: mathgroup at smc.vnet.net
- Subject: [mg49379] AW: [mg49363] How to extract a solution from Mathematica's answer to "Solve"
- From: Matthias.Bode at oppenheim.de
- Date: Sat, 17 Jul 2004 06:38:42 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Hi Rainer, please try: sol = Solve[x^2 - 6*x - 16 == 0, x] sol01 = sol[[1,1,2]] sol01 = sol[[2,1,2]] Best regards, Matthias Bode Sal. Oppenheim jr. & Cie. KGaA Untermainanlage 1 D-60329 Frankfurt am Main GERMANY Tel.: +49(0)69 71 34 53 80 Mobile: +49(0)172 6 74 95 77 Fax: +49(0)69 71 34 95 380 E-mail: matthias.bode at oppenheim.de Internet: http://www.oppenheim.de -----Ursprüngliche Nachricht----- Von: wilhelm.rainer at gmx.net [mailto:wilhelm.rainer at gmx.net] Gesendet: Freitag, 16. Juli 2004 12:07 An: mathgroup at smc.vnet.net Betreff: [mg49363] How to extract a solution from Mathematica's answer to "Solve" I have a question concerning the Solve command. Assume I have solved an equation using Solve. Mathematica returns the solutions in the following form (example for 2 solutions): {{x->-2}, {x->2}} Now, assume I wish always to pick the first of these two solutions and store it in a variable (to be able to continue working with it in the Notebook). Is there a command to "extract" the second solution and to store it in a variable. Since the response is in a form of a matrix {{...},{...}}, I have tried things like MySolution = %[[1]], but it always fails. I appreciate any helpful commands! Thanks Rainer