-6
$\begingroup$

Write a function areaPerimeter[f,g,x] which takes as input two polynomials f and g depending on the variable x, and does the following.

  • If the curves y=f(x) and y=g(x) intersect at exactly two points, compute the area and perimeter of the region enclosed by these curves. Produce a plot showing the two curves with a black dot at each intersection point. Choose a scale on the x-axis so that the enclosed region in clearly visible, with a suitable amount of space on either side. Give the plot a title (use the PlotLabel option) which is the list {area, perimeter}.
  • If the curves do not intersect at exactly two points, produce a plot of the two curves on the interval [-5,5] and set the title of the plot to be "Curves do not have exactly two intersections."
  • Once your function is complete, test it by running the following commands.

You must include the output of these commands in your solution.

enter image description here

enter image description here

$\endgroup$

closed as off-topic by Henrik Schumacher, MarcoB, m_goldberg, b3m2a1, bbgodfrey Mar 29 at 0:57

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Henrik Schumacher, MarcoB
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    $\begingroup$ Kenny, this is the third homework question you post this afternoon, without showing what you have tried so far. Show us what you've tried. Otherwise I'm afraid that this will just be downvoted and closed. $\endgroup$ – MarcoB Mar 28 at 23:06
  • 1
    $\begingroup$ I'm voting to close this question as off-topic because this is clearly a homework question without any put towards coming up with a solution $\endgroup$ – b3m2a1 Mar 29 at 0:01
2
$\begingroup$
area[f_, g_, x_] := NIntegrate[g - f, {x, x1, x2}] // N;

x1 = x /. First[Solve[f[x] == g[x], x] // N]
x2 = x /. Last[Solve[f[x] == g[x], x] // N]


area[x^2, x + 1, x]

Plot[{g[x], f[x]}, {x, -2, 2},
 Epilog -> {{Black, PointSize@Large, Point[{x1, f[x1]}]}, {Black, 
    PointSize@Large, Point[{x2, f[x2]}]}}]

enter image description here

$\endgroup$

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