Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #12560 > unrolled thread

Re: Color according to concavity

Started by"djmpark" <djmpark@comcast.net>
First post2012-12-03 08:38 +0000
Last post2012-12-03 08:38 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Color according to concavity "djmpark" <djmpark@comcast.net> - 2012-12-03 08:38 +0000

#12560 — Re: Color according to concavity

From"djmpark" <djmpark@comcast.net>
Date2012-12-03 08:38 +0000
SubjectRe: Color according to concavity
Message-ID<k9hodt$vb$1@smc.vnet.net>
Bob Hanlon got the trick by setting ColorFunctionScaling to False. But one
thing I notice is that the curve no longer has antialiasing.

I don't know if the following qualifies as brute force, but it is rather
intuitively simple with Presentations and one obtains better looking curves
with antialiasing.

<< Presentations` 

f[x_] := x^2 - x^3 + 10 x 

Draw2D[
 {Red, Draw[f[x], {x, -5, 5}, RegionFunction -> (f''[#] > 0 &)],
  Blue, Draw[f[x], {x, -5, 5}, RegionFunction -> (f''[#] < 0 &)]},
 Frame -> True, AspectRatio -> 1/2] 

For Bob Hanlon's example:

g[x_] := Sin[x] Cos[2 x]

Draw2D[
 {Red, Draw[g[x], {x, -5, 5}, RegionFunction -> (g''[#] > 0 &)],
  Blue, Draw[g[x], {x, -5, 5}, RegionFunction -> (g''[#] < 0 &)]},
 Frame -> True, AspectRatio -> 1/GoldenRatio]

Or do it with a Show.

David Park
djmpark@comcast.net 
http://home.comcast.net/~djmpark/index.html 




From: Murray Eisenberg [mailto:murray@math.umass.edu] 



On Nov 29, 2012, at 6:04 AM, Sergio Miguel Terrazas Porras
<sterraza@uacj.mx> 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@math.umass.edu
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






[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web