1
$\begingroup$

I am a software developer, and it has been far too long since the last time I've needed to do any math this complicated. I've forgotten a lot of the proper terminology, which has made finding answers difficult. I apologize if this question has been asked and answered before.

I have a function with a boatload of inputs. These inputs all have their own valid input domain (I believe that's the right word) and one has its own stepping (steps of 100 instead of 1). They are all also inputs for a function, and I am attempting to calculate the maximum and minimum output given all possible combination of inputs. Which combination of functions must I use to achieve this?

EDIT: Here's an example:

Given the variables a, b, c, and d, with a having a range of -99 to 99, b having a range of 0 to 1000, but only counted in steps of 100, c having a range of -500 to 0, and d having a range of 0 to 50, find the minimum and maximum output for the function ((a * b) / 1000) * c + d.

$\endgroup$

closed as off-topic by m_goldberg, C. E., LCarvalho, LouisB, Alex Trounev Oct 8 at 20:35

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

  • "This question cannot be answered without additional information. Questions on problems in code must describe the specific problem and include valid code to reproduce it. Any data used for programming examples should be embedded in the question or code to generate the (fake) data must be included." – m_goldberg, LCarvalho
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Can we have a concrete example of the kind of problem you are trying to solve? $\endgroup$ – m_goldberg Sep 19 at 12:13
  • $\begingroup$ I have provided an example as you asked. I should have done so in my original question. $\endgroup$ – sonicbhoc Sep 19 at 12:43
5
$\begingroup$

Look at FunctionRange

Clear["Global`*"]

f[a_, b_, c_] := a^b + c

FunctionRange[
 {f[a, b, c], 1 <= a <= 10, 0 <= b <= 3, 0 <= c <= 100},
 {a, b, c}, y]

enter image description here

EDIT: Alternatively, use MinValue and MaxValue

f[a_, b_, c_, d_] = ((a*b)/1000)*c + d;

cond = {-99 <= a <= 99, 0 <= b <= 1000, -500 <= c <= 500, 0 <= d <= 50};

{fmin, fmax} = (#[{f[a, b, c, d], cond}, {a, b, c, d}] & /@ 
  {MinValue, MaxValue})

(* {-49500, 49550} *)

EDIT 2: To include constraints on values of c

cond = {-99 <= a <= 99, 0 <= b <= 1000, -500 <= c <= 500, 0 <= d <= 50, 
   c == 100*n, Element[n, Integers]};

{fmin, fmax} = (#[{f[a, b, c, d], cond}, {a, b, c, d, n}] & /@ {NMinValue, 
    NMaxValue})

(* {-49500., 49550.} *)
$\endgroup$
  • $\begingroup$ This gets me most of the way there. If you get a chance, can you look at my updated question? It provides more information on what I'm actually trying to do. I appreciate the help! $\endgroup$ – sonicbhoc Sep 19 at 12:41
  • $\begingroup$ Thank you! I'm still not exactly sure on how to do stepping (I'm not even sure what the proper mathematical term for that is), but I have a lot more to work with now. $\endgroup$ – sonicbhoc Sep 19 at 19:20
  • $\begingroup$ I tried applying the advice you gave in Edit 2, but I get the error "100n is not a valid variable." Apparently products can't be used as variables? $\endgroup$ – sonicbhoc Sep 19 at 20:19
  • $\begingroup$ Never mind, that Clear["Global`*"] statement was more important than I realized it was. $\endgroup$ – sonicbhoc Sep 19 at 20:30

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