MathGroup Archive 2012

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

Search the Archive

Re: How to Extract Conditional Expression?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg127589] Re: How to Extract Conditional Expression?
  • From: Bob Hanlon <hanlonr357 at gmail.com>
  • Date: Sun, 5 Aug 2012 14:58:34 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net
  • References: <20120805063431.92A6F6766@smc.vnet.net>

expr = x -> ConditionalExpression[#1^2 + 3 #1 + 2 C[1], C[1] in Integers];

f[x_] = expr[[-1, 1]] /. {Slot[1] -> x, C[1] -> 3}

6 + 3 x + x^2

However, I suspect that the condition is actually Element[C[1], Integers]

expr = x ->
   ConditionalExpression[#1^2 + 3 #1 + 2 C[1], Element[C[1], Integers]];

f[x_] = Assuming[expr[[-1, -1]], Simplify[expr[[-1]]]] /. {Slot[1] -> x,
   C[1] -> 3}

6 + x (3 + x)

And if the original expr also actually included a pure function

expr = x ->
   ConditionalExpression[#1^2 + 3 #1 + 2 C[1] &, Element[C[1], Integers]];

f[x_] = Assuming[expr[[-1, -1]], Simplify[expr[[-1]] /. C[1] -> 3]][x]

6 + 3 x + x^2

Depending on how your original expression was generated, you might be
able to remove the condition earlier with an option such as
GenerateConditions -> False


Bob Hanlon


On Sun, Aug 5, 2012 at 2:34 AM, ScottG <sbg at acw.com> wrote:
> I have ...
>
> x -> ConditionalExpression[#1^2 + 3 #1 + 2 C[1],   C[1] in Integers]
>
> and I want
>
> f[x_] = x^2 + 3 x + 6
>
> How do I get there other than cut-and-paste?
>
> Thanks for any insight.
>
> Cheers, Scott
>
>
>



  • Prev by Date: Re: PDF.exe inside Mathematica.app on OS X
  • Next by Date: Re: How to swap two elements of a list
  • Previous by thread: How to Extract Conditional Expression?
  • Next by thread: Re: How to Extract Conditional Expression?