# Help with assignment

#### Gersrus71

Last edited by a moderator:

#### Denis

Math Team
What do you expect? No math teacher?

#### idontknow

$$\displaystyle a+b=20 \;$$ a,b positive integers , max$$\displaystyle (a^2 b )=?$$
$$\displaystyle a^2 b=20a^2 -a^3 \;$$ now by derivatives $$\displaystyle 40a-3a^2=0 \;$$ gives $$\displaystyle a=40/3$$ , but it must be an integer so choose the nearest integer less than $$\displaystyle 40/3$$ which is $$\displaystyle 13$$ and $$\displaystyle b=7$$ .
The maximal value $$\displaystyle a^2 b$$ can take is $$\displaystyle 13^2 \cdot 7 =1183$$ .

• 3 people

#### SDK

but it must be an integer so choose the nearest integer less than $$\displaystyle 40/3$$ which is $$\displaystyle 13$$ and $$\displaystyle b=7$$ .
Everything up to here is fine but this reasoning is completely invalid. There are countless counterexamples and the subject of integer linear programming exists because you can't do optimization on the integers by doing optimization on the reals and then looking "nearby" for an integer solution.

#### Gersrus71

What do you expect? No math teacher?
Iâ€™m doing distance learning so no I donâ€™t have a teacher as such.
I havenâ€™t done Maths since school so Iâ€™m struggling a bit so was just looking for some pointers

#### mathman

Forum Staff
Everything up to here is fine but this reasoning is completely invalid. There are countless counterexamples and the subject of integer linear programming exists because you can't do optimization on the integers by doing optimization on the reals and then looking "nearby" for an integer solution.
Although your statement is true in general, the approach works in this case, where it is maximizing a polynomial.

#### SDK

Although your statement is true in general, the approach works in this case, where it is maximizing a polynomial.
I'm aware that in this case it happens to give the correct answer. My comment was intended to point out the flaw in logic. If a student turned in something like that with the "right" answer and that explanation it would be graded pretty harshly.

Also, it has nothing to do with being a polynomial. One proof that it works in this example easily follows from the AM/GM inequality. So more generally it will work for monomials. I can't see any structure that is more general which would make this still work. It is definitely false for polynomials in general. Here is a simple counterexample.

$p(x) = -\frac{118}{75}x^4 + \frac{758}{75}x^3 - \frac{3121}{150}x^2 + \frac{2141}{150}x$

is a polynomial with rational coefficients even. Its easy to check that if you maximize this on $[0,4]$ the maximum is at $x = 2.5$. But $p(2) = p(3) = 1$ are not the maximum over the integers since $p(1) = 2$. This example wasn't particularly hard to generate.

Last edited:
• 1 person

#### idontknow

The derivatives are not a method for integer variables .
But using the graph and a bit of brute force is easy to find the maxima and minima.
If the local extremum exists , then one of the ineger parts like floor(x) or ceil(x) will be the point of extremum for integers , if the integers are in the domain .
Also knowing whether the function is increasing or decreasing in interval we want .

Last edited:

#### SDK

The derivatives are not a method for integer variables.
But using the graph and a bit of brute force is easy to find the maxima and minima.

If the local extremum exists , then one of the ineger parts like floor(x) or ceil(x) will be the point of extremum for integers , if the integers are in the domain .
Also knowing whether the function is increasing or decreasing in interval we want .
I'm confused. First you agree that derivatives should not be used for integer optimization, but then you say it works. To address your claims specifically:
1. "The derivatives are not a method for integer variables."

I agree

2. "But using the graph and a bit of brute force is easy to find the maxima and minima."

I'm not sure how the graph helps here. The graph of what function? How is determining the graph easier than determining where max/min values are? I agree that for this problem the "correct" answer is to brute force search the integers in the domain.

3. "If the local extremum exists , then one of the ineger parts like floor(x) or ceil(x) will be the point of extremum for integers , if the integers are in the domain ."

This is false which was my entire point. I have provided a counterexample above. What is worse is that this isn't even "usually" true in practice. Hence the reason for point (1). You shouldn't use calculus to optimize over integers.

4. "Also knowing whether the function is increasing or decreasing in interval we want ."

Determining where a function is increasing/decreasing is no easier than optimizing it. In fact, they are equivalent at best since obviously if you know whether the function is increasing/decreasing at every point, then you must know where it attains max/min values. But typically this question is even harder. Moreover, you would still need to know where it takes integral values which is even harder than that.

• 1 person

#### Gersrus71

Thatâ€™s all good stuff lads but none of it really helps with any of my problems... well apart from 1.
Does anyone have any pointers to helping me out with any of the other stuff?