Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #11235
| From | Bob Hanlon <hanlonr357@gmail.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: How to Extract Conditional Expression? |
| Date | 2012-08-05 22:05 +0000 |
| Message-ID | <jvmqmn$a9a$1@smc.vnet.net> (permalink) |
| References | <20120805063431.92A6F6766@smc.vnet.net> |
| Organization | Time-Warner Telecom |
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@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
>
>
>
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Re: How to Extract Conditional Expression? Bob Hanlon <hanlonr357@gmail.com> - 2012-08-05 22:05 +0000
csiph-web