Services & Resources / Wolfram Forums / MathGroup Archive

MathGroup Archive 2012

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

Search the Archive

Re: Color according to concavity

  • To: mathgroup at
  • Subject: [mg128851] Re: Color according to concavity
  • From: Murray Eisenberg <murray at>
  • Date: Fri, 30 Nov 2012 05:57:45 -0500 (EST)
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:
  • References: <>

On Nov 29, 2012, at 6:04 AM, Sergio Miguel Terrazas Porras <sterraza at> wrote:
> I want to plot a function with the color of the parts of the curve according to concavity, say Red when concve down an blue when concave up.
> I can do it by brute force, finding whwn the second derivative is cero, and then finding the sign of it in the different intervals, etc. This for particular examples.
> But, is there a way to use the second derivative as part of a ColorFunction, or something like that?

One might think the following would work, but it doesn't. (The color erroneously remains constant after the local minimum.)

  f[x_] := x^2 - x^3 + 10 x
  Plot[f[x], {x, -5, 5},
        ColorFunction -> Function[{x, y}, If[f''[x] < 0, Red, Blue]]

Murray Eisenberg                                    
murray at
Mathematics & Statistics Dept.      
Lederle Graduate Research Tower            phone 413 549-1020 (H)
University of Massachusetts                               413 545-2838 (W)
710 North Pleasant Street                         fax   413 545-1801
Amherst, MA 01003-9305

  • Prev by Date: Mathematica 9--Is This A Joke?
  • Next by Date: Re: Color according to concavity
  • Previous by thread: Re: Color according to concavity
  • Next by thread: Re: Color according to concavity