MathGroup Archive 2002

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

Search the Archive

RE: RE: Definitions of the functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg34993] RE: [mg34977] RE: [mg34963] Definitions of the functions
  • From: "DrBob" <majort at cox-internet.com>
  • Date: Tue, 18 Jun 2002 02:48:36 -0400 (EDT)
  • Reply-to: <drbob at bigfoot.com>
  • Sender: owner-wri-mathgroup at wolfram.com

I think UnitStep would be easier to use if we could define the function
this way:

y2[x_] := 
  x UnitStep[-x - 5] + x^2 UnitStep[x + 5]UnitStep[18 - x] + 
    Sin[x]UnitStep[x - 18]

or

y3[x_] := 
  x UnitStep[-x - 5] + x^2 UnitStep[x + 5, 18 - x] + Sin[x]UnitStep[x -
18]

Either of these gives the same function values (except at -5 and 18),
but Integrate doesn't evaluate either of them.

Bobby

-----Original Message-----
From: David Park [mailto:djmp at earthlink.net] 
To: mathgroup at smc.vnet.net
Subject: [mg34993] [mg34977] RE: [mg34963] Definitions of the functions

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
djmp at earthlink.net
http://home.earthlink.net/~djmp/




> 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: How to compute a MatrixPower using: A^n = P D^n Inverse[P]
  • Next by Date: RE: Trace a function
  • Previous by thread: RE: Definitions of the functions
  • Next by thread: Trace a function