5
$\begingroup$

Question is given: Consider the functions $f(x)=x \cos(x)$, $g(x)=-x^3+6$, $h(x)=-10x-50$, $k(x)=sin(x^2/3)+13$.

  1. Plot the graphs of the four functions for x in the interval [-8,5]. You should see a region R enclosed by the graphs. Choose a scale for the y axis so that the region is clearly visible. Find the four intersection points that define the corners of the region, and draw a black dot at each point. Note: The region that must be calculated is approx between when x=-6, x=2, x=-1 and y=12, we're not interested in the region where g(x) and h(x) intersect at (5,-100)

  2. Find the area of R given in numerical

My approach:

f = x*Cos[x]
g = -x^3 + 6
h = -10*x - 50
k = Sin[x^2/3] + 13

fCurves = Plot[{f, g, h, k}, {x, -8, 5}, PlotLegends -> "Expressions"]

enter image description here

ActReg = Curves = Plot[{f, g, h, k}, {x, -8, 2.5},
  PlotLegends   ->"Expressions"]

enter image description here

Area = RegionPlot[y > f && y < g && y > h && y < k, {x, -8, 3}, {y, -50, 
50}, PlotPoints -> 200, FrameLabel -> {x, y}]

fg = x /. NSolve[f == g, x, Reals];
fh = x /. NSolve[f == h, x, Reals];
kg = x /. NSolve[k == g, x, Reals];
kh = x /. NSolve[k == h, x, Reals];
Column[{fg, fh, kg, kh}]

My problem was the intersection points. Since the equations are working with respect to x, how do you get the y coordinates for each intersected point?

I tried NSolve but only gave me x coordinates, which looks correct in terms of the values for x but is missing the y coordinates.

$\endgroup$
  • 4
    $\begingroup$ This site is not for us to do your homework problems. $\endgroup$ – David G. Stork Mar 15 '18 at 18:00
  • 2
    $\begingroup$ "Since the equations are working with respect to x, how do you get the y coordinates for each intersected point". Ah. You found x satisfying f[x]==g[x] , the "y" value is just f[x] no? $\endgroup$ – george2079 Mar 15 '18 at 18:16
  • $\begingroup$ Yes I believe so $\endgroup$ – mastud89 Mar 15 '18 at 18:28
  • 2
    $\begingroup$ @DavidG.Stork OP has put some effort though. $\endgroup$ – Kuba Mar 15 '18 at 19:56
  • 5
    $\begingroup$ @mastud89 if so and if you know you can do x /. NSolve then you can also do {x, f} /. NSolve $\endgroup$ – Kuba Mar 15 '18 at 19:57
3
$\begingroup$

First, we define the functions as such and solve with replacement rules to find the corner points for the region of interest:

f = Function[ x, x Cos[x] ];
g = Function[ x, -x^3 + 6 ];
h = Function[ x, -10 x - 50];
k = Function[ x, Sin[x^2/3] + 13];

p1 = {x, h[x]} /. First @NSolve[ f[x] == h[x], x, Reals];
p2 = {x, g[x]} /. First@NSolve[ g[x] == k[x], x, Reals];
p3 = {x, k[x]} /. First@NSolve[ k[x] == h[x], x, Reals];
p4 = {x, f[x]} /. First@NSolve[ f[x] == g[x], x, Reals];

{p1, p2, p3, p4} // Grid[#, Alignment -> Decimal] &

Points

plot = Plot[
  Evaluate@Through[{f, g, h, k}@x], {x, -8, 5},
  PlotRange -> {{-8, 5}, {-20, 20}},
  Epilog -> {Red, PointSize[0.02], Point@{p1, p2, p3, p4}},
  PlotLabels -> Automatic
]

Corners

Now we can define the relevant regions (e.g. halfplanes) with regard to the functions and define their intersection as the region of interest:

rf = ImplicitRegion[ y >= f[x], {x, y}];
rg = ImplicitRegion[ y <= g[x], {x, y}];
rh = ImplicitRegion[ y >= h[x], {x, y}];
rk = ImplicitRegion[ y <= k[x], {x, y}];

intersection = RegionIntersection @@ {rf, rg, rh, rk};

The intersection is a region which can immediately be displayed using Region:

Region[intersection, PlotRange -> {{-8, 5}, {-5, 20}}]

Region of Interest

Its area can be found using Area:

Area @ intersection // N

65.6591

$\endgroup$
  • $\begingroup$ kglr has given a wonderfully concise and compact solution (+1, of course). Here I wanted to be more explicit and also demonstrate the use of regions to reach an answer. $\endgroup$ – gwr Mar 16 '18 at 12:03
9
$\begingroup$
Show[RegionPlot[Max[f, h] <= y <= Min[g, k], {x, -8, 5}, {y, -5, 15}, PlotPoints -> 100], 
 Plot[{f, g, h, k}, {x, -8, 5}, PlotLegends -> "Expressions"]]

enter image description here

NIntegrate[Boole[Max[f, h] <= y <= Min[g, k]], {x, -8, 5}, {y, -30, 30}]

65.68095

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.