Re: Graphing piecewise functions?
[Prev][Next][Index][Thread]
Re: Graphing piecewise functions?
At 10:56 PM -0400 10/14/98, Charlie Reno wrote:
>On Wed, 14 Oct 1998, Kasper Vibe Grevsen wrote:
>> How do I graph
>>
>> x^2 for x<0
>> f(x)={
>> sqrt(x) for x>=0
>>
>> I know you would say y1=(x<0)x^2+(x>=0)sqrt(x) but that does not work
>> because sqrt(x) is undefined for negative x values.
>>
>> I tried graphing y1=(x<0)x^2 and y2=(x>=0)sqrt(x) but it is not very handy
>> and it results in some grim line.
>
>It is great to have a single expression so that you can easily integrate
>from -2 to 2, for example.
>Try
> y1 = x^2*(x<0) + sqrt(abs(x))*(x>=0)
Or, you could use:
y1 = x^2*(x<0) + sqrt(x*(x>=0))
(Note the locations of the parentheses for the sqrt expression.)
Darryl K. Nester E-mail: mailto:nesterd@bluffton.edu
Assoc. Prof. of Mathematics WWW: http://www.bluffton.edu/~nesterd
Bluffton College Phone: 419-358-3483
Bluffton, OH 45817-1704 Fax: 419-358-3232
References: