MathGroup Archive 2002

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

Search the Archive

RE: Choose one solution in Mathematica

  • To: mathgroup at smc.vnet.net
  • Subject: [mg36116] RE: [mg36095] Choose one solution in Mathematica
  • From: "David Park" <djmp at earthlink.net>
  • Date: Thu, 22 Aug 2002 04:32:53 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Roberto,

One method is to use the Cases statement. Let's choose an equation that
actually has positive and negative solutions.

Solve[x^2 - 1 == 0, x]
Cases[%, HoldPattern[Rule[x, _?NonNegative]], \[Infinity]]
{{x -> -1}, {x -> 1}}
{x -> 1}

This was slightly tricky because the Cases statement has several forms, one
of which has a rule as the second argument. We don't intend that case, so we
have to put the rule pattern we are trying to match in a HoldPattern.

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

From: Roberto [mailto:roberto.de_santis at ecb.int]
To: mathgroup at smc.vnet.net

Dear all,

Assume that

x^2 - 2x + 1 = 0

The two solutions are x = -1 and x = 1.
If I assume that x > 0, then the only relevant solution would be x = 1.

How can I tell this to Mathematica?

Solve[x^2 - 2x + 1 = 0, x]

and then........

Many thanks.

Roberto De Santis



  • Prev by Date: RE: Choose one solution in Mathematica
  • Next by Date: Re: function mySet[]
  • Previous by thread: RE: Choose one solution in Mathematica
  • Next by thread: peak separation