0
$\begingroup$

I have the following profit function which I would like to 3Dplot in Mathemathica:

Profit = (8c^2-16c*s-10c-4s-3)/(32s+16)

, where c denotes marginal cost.

with the defined ranges:

0 <= c <= 1/2 and 0 < s < (3+2c)/4

c > 1/2 and (-1+2c)/4 < s < (3+2c)/4

Currently, I only know how to 3Dplot a function with real numbers. Fx:

Plot3D[8 c^2 - 16 c s - 10 c - 4 s - (3 s)/32 + 16, {c, 0, 2}, {s, 0, 
  1}]

I get an error if I do something like this:

Plot3D[((8 c^2 - 16* c* s - 10 c - 4 s - 3)/(32 s + 16)), {c, 
    0, (1/2)}, {s, 0, ((3 + 2 c)/4)}, {c, (1/2), 
    inf}, {s, ((-1 + 2 c)/4)}, ((3 + 2 c)/4)} ]
$\endgroup$
  • $\begingroup$ Does this do it? Plot3D[profit, {c, 0, 2}, {s, 0, 1}, RegionFunction -> Function[Or[ 0 <= #1 <= 1/2 && 0 <= #2 <= (3 + 2 #1)/4, #1 > 1/ 2 && (-1 + 2 #1) < #2 < (3 + 2 #1)/4]]] $\endgroup$ – march Apr 13 '16 at 15:36
  • $\begingroup$ @march just tried. The output is an empty box. $\endgroup$ – Saud Apr 13 '16 at 18:33
  • $\begingroup$ Probably because I used profit instead of Profit. Capitalization matters. Also, you should add PlotRange -> All to the list of options. $\endgroup$ – march Apr 13 '16 at 19:02
  • $\begingroup$ Corrected profit to Profit and added PlotRange -> All at the end: Plot3D[Profit, {c, 0, 2}, {s, 0, 1}, RegionFunction -> Function[Or[ 0 <= #1 <= 1/2 && 0 <= #2 <= (3 + 2 #1)/4, #1 > 1/2 && (-1 + 2 #1) < #2 < (3 + 2 #1)/4]], PlotRange -> All] I still get an empty box. $\endgroup$ – Saud Apr 14 '16 at 11:10
1
$\begingroup$

The proposed snippets are working on 10.0 for Mac OS X x86 (64-bit) (December 4, 2014)

ClearAll["Global`*"]

Profit = (8 c^2 - 16 c*s - 10 c - 4 s - 3)/(32 s + 16)

$\frac{8 c^2-16 c s-10 c-4 s-3}{32 s+16}$

Plot3D[Profit, {c, -0.286031, 0.286031}, {s, -0.347656, 0.347656}]

enter image description here

Plot3D[8 c^2 - 16 c s - 10 c - 4 s - (3 s)/32 + 16, {c, 0, 2}, {s,  0, 1}]

enter image description here

Plot3D[Profit, {c, 0, 2}, {s, 0, 1}, 
RegionFunction -> 
Function[Or[
 0 <= #1 <= 1/2 && 
  0 <= #2 <= (3 + 2 #1)/4, #1 > 
   1/2 && (-1 + 2 #1) < #2 < (3 + 2 #1)/4]]]

enter image description here

Plot3D[Profit, {c, 0, 2}, {s, 0, 1}, 
RegionFunction -> 
Function[Or[
 0 <= #1 <= 1/2 && 
  0 <= #2 <= (3 + 2 #1)/4, #1 > 
   1/2 && (-1 + 2 #1) < #2 < (3 + 2 #1)/4]], PlotRange -> All]

enter image description here

$\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.