# How can I find the minimum and maximum output of a function and specify the valid ranges and steping of each variable? [closed]

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.

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

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] 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.} *)

• 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! – sonicbhoc Sep 19 '19 at 12:41
• 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. – sonicbhoc Sep 19 '19 at 19:20
• 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? – sonicbhoc Sep 19 '19 at 20:19
• Never mind, that Clear["Global*"] statement was more important than I realized it was. – sonicbhoc Sep 19 '19 at 20:30