MathGroup Archive 2009

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

Search the Archive

Piecewise vs. /; ?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg103899] Piecewise vs. /; ?
  • From: Erik Max Francis <max at alcyone.com>
  • Date: Sun, 11 Oct 2009 08:06:46 -0400 (EDT)

I'm defining a piecewise function:

mmin = 0.08;
mmax = 100;

\[Xi][m_] := Piecewise[
    {{0.035 m^-1.3, 0.08 <= m <= 0.50},
     {0.019 m^-2.2, 0.50 < m <= 1.00},
     {0.019 m^-2.7, 1.00 < m <= 100}}]; (* stars per pc^3 *)

This works fine for plotting (which I won't show) and integrating:

In[5]:= Integrate[\[Xi][m], {m, mmin, mmax}]

Out[5]= 0.136978

If I try to define \[Xi][m] with /;, it doesn't work.  This version:

\[Xi][m_ /; 0.08 <= m <= 0.50] = 0.035 m^-1.3 ;
\[Xi][m_ /; 0.50 < m <= 1.00] = 0.019 m^-2.2;
\[Xi][m_ /; 1.00 < m <= 100] = 0.019 m^-2.7;
(* stars per pc^3 *)

plots correctly but integrate refuses to do anything:

In[26]:= Integrate[\[Xi]2[m], {m, mmin, mmax}]

Out[26]= \!\(
\*SubsuperscriptBox[\(\[Integral]\), \(0.08`\), \(100\)]\(\[Xi]2[
    m] \[DifferentialD]m\)\)

This version (putting the /; in a different place):

\[Xi]3[m_] = 0.035 m^-1.3  /; 0.08 <= m <= 0.50;
\[Xi]3[m_] = 0.019 m^-2.2 /; 0.50 < m <= 1.00;
\[Xi]3[m_] = 0.019 m^-2.7 /; 1.00 < m <= 100;
(* stars per pc^3 *)

neither plots properly (the plot is blank) nor integrates properly:

In[27]:= Integrate[\[Xi]3[m], {m, mmin, mmax}]

Out[27]= \!\(
\*SubsuperscriptBox[\(\[Integral]\), \(0.08`\), \(100\)]\(\((
\*FractionBox[\(0.035`\),
SuperscriptBox[\(m\), \(1.3`\)]] /;
     0.08` <= m <= 0.5`)\) \[DifferentialD]m\)\)

I was under the impression that these were equivalent; what am I missing?

-- 
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
  San Jose, CA, USA && 37 18 N 121 57 W && AIM/Y!M/Skype erikmaxfrancis
   If you're not beside me / I'll do your best / To carry on
    -- India Arie


  • Prev by Date: Re: Convert Graphics3D to Graphics2D. Is it possible?
  • Next by Date: Re: Google Trends Data and Mathematica
  • Previous by thread: update of Synergetics coordinates Notebook
  • Next by thread: Re: Piecewise vs. /; ?