RE: Definitions of the functions

• To: mathgroup at smc.vnet.net
• Subject: [mg34977] RE: [mg34963] Definitions of the functions
• From: "David Park" <djmp at earthlink.net>
• Date: Mon, 17 Jun 2002 03:26:53 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```Pawes,

For plotting and arithmetic...

y[x_] /; x < -5 := x
y[x_] /; -5 <= x < 18 := x*x
y[x_] := Sin[x]

Plot[y[x], {x, -10, 30},
PlotRange -> All];

For calculus...

Clear[y];
y[x_] = x(1 - UnitStep[x + 5]) + x*x(UnitStep[x + 5] - UnitStep[x - 18]) +
Sin[x]UnitStep[x - 18] // Simplify
(-x^2 + Sin[x])*UnitStep[-18 + x] +
x*(1 + (-1 + x)*UnitStep[5 + x])

g[x_] = Integrate[y[x], x] // Simplify
(1/6)*(3*x^2 - 2*(-5832 + x^3 - 3*Cos[18] + 3*Cos[x])*
UnitStep[-18 + x] + (325 - 3*x^2 + 2*x^3)*
UnitStep[5 + x])

Plot[g[x], {x, -10, 30},
PlotRange -> All];

David Park

> From: Pawe³ Ga³ecki [mailto:pmg at wp.pl]
To: mathgroup at smc.vnet.net
>
>
> How do I define a function that is described by different
> formulas depending
> of the interval which the argument is given in????
> For example:
>
> y=x             for  -inf<x<-5
> y=x*x          for  -5<=x<18
> y=sin x        for all the remaining values of x.
>
>
> Anybody got a clue???
>
> Thanks,
> Pawe³ Ga³ecki
>

```

• Prev by Date: Re: Plot a sample path of a bornian motion
• Next by Date: Re: How to compute a MatrixPower using: A^n = P D^n Inverse[P]
• Previous by thread: Re: Definitions of the functions
• Next by thread: RE: RE: Definitions of the functions