Message Boards Message Boards

0
|
12519 Views
|
6 Replies
|
6 Total Likes
View groups...
Share
Share this post:

Area between 2D cartesian curves, fill between two ordinates, for calculus

Posted 11 years ago
I have not been successful in finding Help information for shading the area between two 2D cartesian curves, from one ordinate x-value to another. For example, displaying graphically the filled area between the graph of y=sinx and y=cosx from x=?/4 to x= 5?/4. Or the filled area between the graph of y=sinx and the x-axis from x=?/4 to x= 5?/4.
POSTED BY: Ian Willson
6 Replies
Posted 11 years ago
Thank you Shenghui, beautiful.
POSTED BY: Ian Willson
You can find the dynamic sweeping area with the following code. It basically lay the filled area above the plot with curves only
 Manipulate[
  Show[
   Plot[{Sin[x], Cos[x]}, {x, Pi/4, k},
    Filling -> {1 -> {{2}, Yellow}}],
   Plot[{Sin[x], Cos[x]}, {x, Pi/4, 5 Pi/4}],
   PlotRange -> {{Pi/4, 5 Pi/4}, {-1, 1}}, Axes -> None,
   Epilog ->
    Inset[Row[{"Area is:",
       NIntegrate[Sin[x] - Cos[x], {x, Pi/4, k}]}], {2.1, 0.1}]
  ], {k, Pi/4 + 0.001, 5*Pi/4}]

POSTED BY: Shenghui Yang
Posted 11 years ago
Thank you, very valuable, will continue my efforts.
POSTED BY: Ian Willson
Posted 11 years ago
There certainly might be a better way of doing this, but does this give you enough of a hint that you can modify this to get what you are looking for?
 Show[{
   Plot[{Sin[x], Cos[x]}, {x, 0, Pi/4}, PlotRange -> {{0, 2 Pi}, {-1.01, 1}}],
   Plot[{Sin[x], Cos[x]}, {x, Pi/4, 5 Pi/4}, Filling -> {1 -> {2}},
    FillingStyle -> Yellow, AxesLabel -> {"x", "y"},
    Ticks -> {{Pi/4, 5 Pi/4, 2 Pi}, {-1, 1}},
    GridLines -> {{{Pi/4, {Red, Dashed,
         Thickness[0.003]}}, {5 Pi/4, {Red, Dashed, Thickness[0.003]}},
        2 Pi}, {-1, -Sqrt[2]/2, Sqrt[2]/2, 1}}],
   Plot[{Sin[x], Cos[x]}, {x, 5 Pi/4, 2 Pi}]
}]
POSTED BY: Bill Simpson
Posted 11 years ago
Thank you Bill. What I would like to do is shade just the area from ?/4 to 5?/4, for domain 0 to 2?. My code so far as follows:
Plot[{Sin[x], Cos[x]}, {x, 0, 2 Pi}, Filling -> {1 -> {2}},
FillingStyle -> Yellow, AxesLabel -> {"x", "y"},
Ticks -> {{Pi/4, 5 Pi/4, 2 Pi}, {-1,  1}},
GridLines -> {{{Pi/4, {Red, Dashed,
      Thickness[0.003]}}, {5 Pi/4, {Red, Dashed, Thickness[0.003]}},
    2 Pi}, {-1, -Sqrt[2]/2, Sqrt[2]/2, 1}}]
POSTED BY: Ian Willson
Posted 11 years ago
On the help page for Filling scroll down and click on Scope and then on FillingStyle and it gives the first example
Plot[{Sin[x], Cos[x]}, {x, Pi/4, 5 Pi/4}, Filling->{1->{{2}, Yellow}}]
POSTED BY: Bill Simpson
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