2
$\begingroup$

I have a function f(A,B,C) where for specific A and B values I can use Reduce to determine the constraint on C for my problem using a constraint on f. I want to plot the resulting surface.

To illustrate, consider

f = A^5 + B^3 + C^2

If A and B vary between 1 and 3 then I get the list of constraints (with f<20)

constraints = {{1, 1, C < 18}, {2, 1, C < -13}, {3, 1, C < -224}, {1, 2, C < 11}, {2, 2, C < -20}, {3, 2, C < -231}, {1, 3, C < -8}, {2, 3, C < -39}, {3, 3, C < -250}}

I then want to plot the surface given by

surf = {{1, 1, 18}, {2, 1, -13}, {3, 1, -224}, {1, 2, 
  11}, {2, 2, -20}, {3, 2, -231}, {1, 3,  -8}, {2, 3, 
   -39}, {3, 3, -250}}

ListPlot3D[surf,Mesh->All]

I can form the list of constraints using For loops

constraints = {};
For[B = 1, B <= 3, B++,
 For[A = 1, A <= 3, A++,
  f = (A)^5 + B^3 + p;
  sol  = Reduce[f < 20, p];
  constraints = Append[constraints, {A, B, sol}]
  ]
 ]
constraints

However I am not sure how to get from the list of constraints to the max permitted value for C and therefore get to the surf expression.

I also expect that For loops are not an ideal approach, and that I should be able to form lists of the A and B values and use another approach (Map, or Thread, or Apply maybe) with Reduce. I find these methods confusing though, and don't really understand anything but the most basic examples (so possibly similar questions have not helped me figure this out).

$\endgroup$
  • $\begingroup$ Are A and B constrained to be integers? $\endgroup$ – Chris K Mar 26 at 8:03
  • $\begingroup$ No they aren't - my actual function is quite complex so this is just a simple example. @Henrik Schumacher's solution works wonderfully, but I'd still like to know how to map across the list if anyone has a solution that works that way (just for general development of skills) $\endgroup$ – Esme_ Mar 26 at 8:16
4
$\begingroup$
f = a^5 + b^3 + c^2
RegionPlot3D[f <= 20, {a, 1, 3}, {b, 1, 3}, {c, -5, 5}, 
 AxesLabel -> {"a", "b", "c"}]

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.