MathGroup Archive 2008

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

Search the Archive

Re: How to find the Max of a Piecewise function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg90431] Re: How to find the Max of a Piecewise function
  • From: Szabolcs Horvát <szhorvat at gmail.com>
  • Date: Wed, 9 Jul 2008 04:53:46 -0400 (EDT)
  • References: <g4vk81$9pv$1@smc.vnet.net>

Aaron Fude wrote:
> Hi,
> 
> If f is deined according to
> 
> f[x_] := Piecewise[{{1, x < 1}, {2, x > 1}}]
> 
> then
> 
> Max[f[Range[0, 1, .001]]]
> 
> does not yield the desired result. What's the proper way to approach
> this?
> 

f is not Listable.  One way to achieve the behaviour you expect is to 
set this attribute on it:

SetAttributes[f, Listable]

But it may be simpler and better to just use Max[f /@ Range[0,1,.001]]


  • Prev by Date: Solving a DE using Mathematica
  • Next by Date: Help with 3 dimensional Fourier Integral
  • Previous by thread: Re: Re: How to find the Max of a Piecewise function
  • Next by thread: Re: How to find the Max of a Piecewise function