Group Abstract Group Abstract

Message Boards Message Boards

Reduce a Piecewise function into single equation?

Hi,

I have created a Piecewise function as below;

Plot[Piecewise[{{-0.3*(1 - 1/(1 + x^4)), x < 0}, {(1 - 1/(1 + x^4)), 
x > 0}}], {x, -10, 10}, PlotRange -> {{-10, 10}, {-2, 1}}]

Is there any way that I can regenerate this function by only a single equation without the Piecewise function? Thanks

2 Replies

How about

   eq2 = -3/10 + (13/10)*HeavisideTheta[x] + 3/(10*(x^4 + 1)) - (13/10)*HeavisideTheta[x]/(x^4 + 1)

   eq3 = -3/10 + (13/10)*UnitStep[x] + 3/(10*(x^4 + 1)) - (13/10)*UnitStep[x]/(x^4 + 1)


   Plot[{eq2, eq3}, {x, -10, 10}, PlotRange -> {{-10, 10}, {-2, 1}}, PlotStyle -> {{Dashed, Thick}, Thin}]

enter image description here

I used Convert Function from Maple. It is a pity that there is no such function in MMA, which converts one function to another.

But from this website:

eq = Piecewise[{{-0.3*(1 - 1/(1 + x^4)), x < 0}, {(1 - 1/(1 + x^4)), x > 0}}];
Simplify`SimplifyUnitStep[Simplify`PWToUnitStep[eq]]

(* x^4/(1 + x^4) - (0.3 x^4)/(1. + x^4) - (x^4 UnitStep[-x])/(
 1 + x^4) + (0.3 x^4 UnitStep[x])/(1. + x^4) *)
POSTED BY: Mariusz Iwaniuk

How about

(1 - 1/(1 + x^4)) Rescale[Sign[x], {-1, 1}, {-.3, 1}]

You may also try UnitStep.

POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard