Message Boards Message Boards

0
|
4664 Views
|
3 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Shading the region between two graphs?

Posted 9 years ago
f[x_] := (1/3) x^3 - (1/2) x^2 - 2 x + (1/3)

g[x_] := x - 1

This is my graph:

Plot[{f[x], g[x]}, {x, -4, 4}]

I integrated and fund the regions

 Integrate[Abs[f[x] - g[x]], {x, -2.5833, 0.42303}]

    7.15574

Integrate[Abs[f[x] - g[x]], {x, 0.42303, 3.66027}]

    8.71687

Now how do I shade in only those regions?

I came up with this but I don't know what to put in the "?"

Plot[{f[x], g[x]}, {x, -4, 4}, Filling -> ?, FillingStyle -> Pink]
POSTED BY: Maddie Long
3 Replies

Look at the documentation for Filling under "Scope" :> "Filling Limits".

This example shows how to fill from the first function to the second function in the list of inputs:

Plot[{Sin[x], Cos[x]}, {x, 0, 2 Pi}, Filling -> {1 -> {2}}]
POSTED BY: Sean Clarke
f[x_] := (1/3) x^3 - (1/2) x^2 - 2 x + (1/3)
g[x_] := x - 1
Plot[{f[x], g[x]}, {x, -4, 4}, Filling -> {1 -> {2}}]
POSTED BY: S M Blinder

enter image description here

POSTED BY: Simon Cadrin
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract