Re: Simplify with If and UnitStep

• To: mathgroup at smc.vnet.net
• Subject: [mg31344] Re: [mg31286] Simplify with If and UnitStep
• From: BobHanlon at aol.com
• Date: Mon, 29 Oct 2001 02:23:29 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```In a message dated 2001/10/26 6:40:51 AM, gg at hugo.doemaarwat.nl writes:

>I finally understand how I can create a 'piecewise' function with
>mathematica with UnitStep, but somewhere further in my calculations it
>doesn't Simplify it at all.
>This is what I've got as a result now (I removed the ugly pieces
>
>If[ 1/(32*t^0.3) > 1 && t^(-0.3) > 32,
> 62000*UnitStep[-0.1 + 32]*UnitStep[-0.1 + 1/t^0.3],
> Integrate[M^2.55*UnitStep[M - 0.1, -M + 32],
>  {M, 0.1, 1/t^0.3}]]
>
>There are a couple of annoying things here that I can't solve...
>
>1) On the first line there are 2 conditions which are exactly the same
>only the 32 is on the other site of the >, how can I turn this into
>just 1 condition? (preferable the latter)
>
>2) On the second line there is a UnitStep[-0.1+32] which is certainly
>1. The second UnitStep is also 1 because the last part there is always
>larger then 32, that's what the If statement implies. How can I get
>these UnitStep's to be 1?
>
>3) On the 3th and 4th line it Integrate's over M in between 0.1 and a
>number lower then 32 (as the If statement implies), so the last
>UnitStep should also be 1.
>
>
>So what I want to see is actualy
>
>If[t^(-0.3) > 32, 62000, -0.00007939 + 0.281/t^1.065]
>
>Which looks way nicer then the upper statement, but essentially the
>same. (I rounded the numbers somewhat, but you get the idea.)
>
>If anyone can give me a hint about what I should do I will be very
>gratefull :-)
>

expr = If[1/(32*t^0.3)>1&&t^(-0.3)>32,
62000*UnitStep[-0.1+32]*UnitStep[-0.1+1/t^0.3],
Integrate[M^2.55*UnitStep[M-0.1,-M+32],
{M,0.1,1/t^0.3}]];

The conditions do not simplify because the two conditions are not "exactly"
the same.
To make them the same, use exact (rational) values.

expr = Simplify[Rationalize[expr]]

If[1/t^(3/10) > 32,
62000*UnitStep[-(1/10) + 32]*
UnitStep[1/t^(3/10) - 1/10],
Integrate[M^(51/20)*UnitStep[M - 1/10,
32 - M], {M, 1/10, 1/t^(3/10)}]]

The arguments to the If are not simplified because If has attribute HoldRest.

Attributes[If]

{HoldRest, Protected}

expr = Module[{d},
expr /. If[a_, b_, c_] :> (If[a, d, c] /.
d -> FullSimplify[b, a])]

If[1/t^(3/10) > 32, 62000,
Integrate[M^(51/20)*UnitStep[M - 1/10,
32 - M], {M, 1/10, 1/t^(3/10)}]]

The easiest way to deal with the integral is just to remove the UnitStep
manually

expr = expr /. UnitStep[x__] -> 1

If[1/t^(3/10) > 32, 62000,
Integrate[M^(51/20)*1, {M, 1/10,
1/t^(3/10)}]]

expr = Release /@ expr

If[1/t^(3/10) > 32, 62000,
20/(71*t^(213/200)) -
1/(3550*10^(11/20))]

Bob Hanlon
Chantilly, VA  USA

```

• Prev by Date: Re: several messages
• Next by Date: Re: RE: Does Mathematica do transparent colors?
• Previous by thread: Re: Simplify with If and UnitStep
• Next by thread: FW: Carriage Return oddity in Mathematica (follow-up)