Re: Color according to concavity

• To: mathgroup at smc.vnet.net
• Subject: [mg128867] Re: Color according to concavity
• From: "djmpark" <djmpark at comcast.net>
• Date: Sat, 1 Dec 2012 04:34:30 -0500 (EST)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com
• Delivered-to: l-mathgroup@wolfram.com
• Delivered-to: mathgroup-newout@smc.vnet.net
• Delivered-to: mathgroup-newsend@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 at comcast.net
http://home.comcast.net/~djmpark/index.html

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

On Nov 29, 2012, at 6:04 AM, Sergio Miguel Terrazas Porras
<sterraza at 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 at 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

```

• Prev by Date: Re: Mathematica 9--Is This A Joke?
• Next by Date: R: Re: Difficult antiderivative
{"ft_lang_label":"__label__en","ft_lang_prob":0.7702417,"math_prob":0.7335207,"size":2395,"snap":"2023-14-2023-23","text_gpt3_token_len":756,"char_repetition_ratio":0.09410289,"word_repetition_ratio":0.08839779,"special_character_ratio":0.34446764,"punctuation_ratio":0.21031746,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.96288925,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-03-21T21:30:09Z\",\"WARC-Record-ID\":\"<urn:uuid:332e3188-6f56-4bef-9d9a-1ce585567d1f>\",\"Content-Length\":\"46261\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:7e95b627-ecf5-4511-bda9-0a4b3670a669>\",\"WARC-Concurrent-To\":\"<urn:uuid:b368e6b4-c2e6-41c3-96e6-5da033452673>\",\"WARC-IP-Address\":\"140.177.205.73\",\"WARC-Target-URI\":\"https://forums.wolfram.com/mathgroup/archive/2012/Dec/msg00009.html\",\"WARC-Payload-Digest\":\"sha1:BTQZ7F3VGN7VDQVA7KGI4X2XZVONLPZI\",\"WARC-Block-Digest\":\"sha1:AN52GZ5NVSXQO4NKLHCNFLMZFA6M5ZGM\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-14/CC-MAIN-2023-14_segments_1679296943746.73_warc_CC-MAIN-20230321193811-20230321223811-00613.warc.gz\"}"}