2
$\begingroup$

A way to find the region such as the area is using $Integrate[]$, where you take the upper - lower or $f[x]-g[x]$, while the perimeter we add the upper and lower region after we found its arc length. However, I'm having trouble finding the area and perimeter using programming.

Given a function $areaPerimeter[f,g,x]$, I am trying to find if the curves intersect ie. $y=f(x)$ and $y=g(x)$.

Using $areaPerimeter[1/10 x^4 + x + 1, x^2 - 1, x]$, I need to display the plot and PlotLabels showing the ${area,perimeter}$ above the plot

My attempt:

areaPerimeter[f_, g_] :=
Plot[{f[x], g[x]}, {x, -2, 4}]

Then I indicated the parameters for the overall plot using Module

areaPerimeter[f_, g_, x_] := Module[{sols, xvals, min, max, p, l},
sols = NSolve[f == g, x, Reals];
xvals = x /. sols;
min = Min[xvals];
max = Max[xvals];
d = max - min;
If[Length[sols] == 0,
  min = -5;
  max = 5;
d = 0
];
If[Length[sols] == 1,
  d = 10;
];
p = Plot[{f, g}, {x, min - 0.2*d, max + 0.2*d}];
l = ListPlot[{x, f} /. sols, PlotStyle -> Black];
Show[p, l]
]
$\endgroup$
6
$\begingroup$
pts = {x, x^2 - 1} /. 
   NSolve[{x^2 - 1 == 1/10 x^4 + x + 1}, x, Reals, WorkingPrecision -> 15];

reg = ImplicitRegion[
   1/10 x^4 + x + 1 <= y <= x^2 - 1 &&
    pts[[1, 1]] <= x <= pts[[2, 1]], {x, y}];

area = Area[reg]

(* 4.19337506922227 *)

Verifying,

area == NIntegrate[1, {x, pts[[1, 1]], pts[[2, 1]]},
  {y, 1/10 x^4 + x + 1, x^2 - 1}]

(* True *)

perimeter = RegionMeasure@RegionBoundary[reg]

(* 21.4130315179935 *)

Verifying,

perimeter == 
 Total[ArcLength[{x, #}, {x, pts[[1, 1]], pts[[2, 1]]}, 
     WorkingPrecision -> 15] & /@ {x^2 - 1, 1/10 x^4 + x + 1}]

(* True *)

Plot[{x^2 - 1, 1/10 x^4 + x + 1}, {x, -3.5, -0.75},
 Filling -> {1 -> {{2}, {White, LightBlue}}},
 Epilog -> {Text[
    "area = " <> ToString@NumberForm[area, {6, 3}], {-2, 10}, {1, 1}],
   Text["perimeter = " <> ToString@NumberForm[perimeter, {6, 3}], {-2, 
     11}, {1, 1}],
   Red, AbsolutePointSize[4], Point[pts]},
 PlotLegends -> Placed["Expressions", {0.6, 0.5}]]

enter image description here

$\endgroup$
5
$\begingroup$
Plot[{x^4/10 + x + 1, x^2 - 1}, {x, -4, 0}, PlotLegends -> Automatic]

enter image description here

reg = ImplicitRegion[x^4/10 + x + 1 <= y <= x^2 - 1, {x, y}];    
Area@reg // N
4.19338

Perimeter@reg // N
21.413

Perimeterintroduced in 2017 (11.1)

$\endgroup$
  • $\begingroup$ What's with that clean up you've done with your answers? :) $\endgroup$ – Kuba Nov 13 '18 at 21:14

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.