2
$\begingroup$

I need to write a function to find the volume under a surface $|f(x, y)|$ and over an certain area. The output of the function is going to be the volume and a plot.

For example:

Given $|f(x,y)|=|3+x^2 - 2y|$ and the area specified by $0<x\leq1 \land -x\leq y<x$

the output should be

enter image description here

Edit

I tried the formulas for integration and plotting, but my code failed. The result that I got was:

try[solid_, x1_ && y1_] :=
  Module[{volume1, plot1},
    volume1 = Integrate[Abs[solid], x1, y1];
    plot1 = Plot3D[Abs[solid], x1, y1];
    Print[volume1];
    Print[plot1]]

try[x^2 + y^2 + 2, -1 <= x <= 1 && 0 <= y <= 1]

Integrate::ilim: Invalid integration variable or limit(s) in -1<=x<=1.
Plot3D::pllim: Range specification -1<=x<=1 is not of the form {x, xmin, xmax}.

(*
  Integrate[Abs[2 + x^2 + y^2], -1 <= x <= 1, 0 <= y <= 1]  
  Plot3D[Abs[2 + x^2 + y^2], -1 <= x <=1, 0 <= y <= 1]
*)

Here is how it looks in my notebook.

enter image description here

What should I change to make the function work?

$\endgroup$
  • 2
    $\begingroup$ This can be easily found in documentation. $\endgroup$ – yarchik Jun 24 at 11:31
  • $\begingroup$ @yarchik excuse me, but what documentation are you talking about? and where can i find it? thank you. $\endgroup$ – loki Jun 24 at 11:39
  • 1
    $\begingroup$ @loki right here for Integrate wolfram.com/xid/0mrb9e-k30pof $\endgroup$ – flinty Jun 24 at 12:04
3
$\begingroup$

Is this what you are after?

Integrate[
  Abs[x^2 - 2 y + 3]
, {x, y} ∈ ImplicitRegion[-x <= y < x, {{x, 0, 1}, y}]
 ]

7/2

Plot3D[
  Abs[x^2 - 2 y + 3]
, {x, y} ∈ ImplicitRegion[-x <= y < x, {{x, 0, 1}, y}]
, Filling -> Axis
]
| improve this answer | |
$\endgroup$
  • $\begingroup$ Unfortunately no. I must use the Module function to complete it. $\endgroup$ – loki Jun 24 at 6:53
  • 2
    $\begingroup$ @loki how about you lookup docs for Module and just wrap this solution with it? $\endgroup$ – Kuba Jun 24 at 7:30

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