0
|
12272 Views
|
6 Replies
|
6 Total Likes
View groups...
Share
GROUPS:

# 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.
6 Replies
Sort By:
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 examplePlot[{Sin[x], Cos[x]}, {x, Pi/4, 5 Pi/4}, Filling->{1->{{2}, Yellow}}]
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 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 11 years ago
 Thank you, very valuable, will continue my efforts.
Posted 11 years ago
 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 11 years ago
 Thank you Shenghui, beautiful.