[Date Index]
[Thread Index]
[Author Index]
Re: piecewise vs which
*To*: mathgroup at smc.vnet.net
*Subject*: [mg60117] Re: [mg60101] piecewise vs which
*From*: Pratik Desai <pdesai1 at umbc.edu>
*Date*: Sat, 3 Sep 2005 02:06:05 -0400 (EDT)
*References*: <200509020833.EAA05912@smc.vnet.net>
*Sender*: owner-wri-mathgroup at wolfram.com
Bradley Stoll wrote:
>Consider defining a function in Mathematica (v. 5.2) in two different
>ways: f[x_]=Piecewise[{{x^2,x<2},{3x,x>2}}] and
>g[x_]=Which[x<2,x^2,x>2,3x]. Notice that 2 is not in the domain of
>either function. However, if I ask for f[2], Mathematica returns 0 and if I ask
>for g[2] Mathematica (correctly) returns nothing.
>
If you look at the help on Piecewise it comes with the following disclosure
Piecewise[{{a, a}, ? }, val] uses default value val if none of the a
apply. The default for val is 0.
Hmm......The other problem might be that this may not be a piecewise
continuous function
Limit[f[x],x->2,Direction->-1]
6
Limit[f[x],x->2,Direction->1]
4
Thanks for bringing this to my attention, I have been using piecewise
with impunity in my codes....may be I should look at them again
Pratik
> Is this a bug with
>Mathematica (that Mathematica returns 0 for f[2]), since 2 is not in the domain?
>While I have eyes, there is another question regarding limits. Is it
>the case that Limit[f[x],x->2] defaulted as
>Limit[f[x],x->2,Direction->-1] (a right hand limit)? Both return 6 in
>the above example. I'm using Mathematica in my calculus class and would
>like to explain why Mathematica does certain things. It doesn't seem
>that it would've been too difficult to just have two subroutines (a
>right and left hand limit) to determine whether a 'full' limit actually
>existed.
>Thanks!
>
>Bradley
>
>
>
--
Pratik Desai
Graduate Student
UMBC
Department of Mechanical Engineering
Phone: 410 455 8134
Prev by Date:
** Re: piecewise vs which**
Next by Date:
**Re: Another damn simplifying problem: ArcTan**
Previous by thread:
**Re: piecewise vs which**
Next by thread:
**Re: piecewise vs which**
| |