How to minimise a function of integers?

In summary: Now: mn must be greater than k^2 as you can see if you expand (mn - 2(n-1)x - 1)^2. But if mn is greater than k^2, then mn - 1 must be greater than k^2 - 1.Since you specified that m/x be an integer, we can say that m/x = k^2 - 1. But if m/x is an integer, then m/(k^2 - 1) must be an integer. But... m/(k^2 - 1) can be written as m/(k + 1)(k - 1). So m/(k + 1) must be an integer
  • #1
weetabixharry
111
0
I want to find the positive integer, [itex]x[/itex], which minimises the following function:[tex]f(x) = (mn - 2(n-1)x - 1)^2[/tex]where [itex]m[/itex] and [itex]n[/itex] are positive integers. I also have the further constraint that:[tex]\frac{m}{x} = \mathrm{positive \ integer}[/tex]I guess calculus might not be a good route to take, since [itex]x[/itex] can only take certain discrete values. Indeed, computing [itex]\frac{d}{dx}f(x)[/itex] and equating to zero gives:[tex]x_{\mathrm{min}}=\frac{mn-1}{2(n-1)}[/tex]which does not necessarily lead us to the correct solution (if we round to the nearest integer factor of [itex]m[/itex]).

Does anyone know how to solve this sort of problem?
 
Last edited:
Mathematics news on Phys.org
  • #2
weetabixharry said:
Does anyone know how to solve this sort of problem?
What is the shape of the function? (as a function of real numbers)
 
  • #3
i personally don't see how you can do better than what you have.
let's say m = 2^4*3^3 = 432
if n is a low value, say 5, i get...
(432*5-1)/(2*(5-1)) = 269; closest factor being 216.

(432*5-2*4*216-1)^2 = 431^2.
no other factor of 432 give a smaller value.
if n is large, say 7^3 = 343...
(432*343-1)/(2*(343-1)) = 216.
again, plugging 216 in we see no factor of m gives a better result.
 
  • #4
Hurkyl said:
What is the shape of the function? (as a function of real numbers)

I'm not sure if I fully understand the question... I have attached a graph showing an example where the minimum value of [itex]f(x)[/itex] (where fractional/non-integer quantities are allowed) does not fall closest to the minimum allowable discrete value.

http://desmond.imageshack.us/Himg801/scaled.php?server=801&filename=shapeu.jpg&res=landing

In this case, the minimum is at [itex]\frac{m}{x}=1.8865[/itex], which is closer to 1 than the optimal value 3. I could probably find more extreme failures, but the shape is generally something like this.
 

Attachments

  • shape.jpg
    shape.jpg
    16.1 KB · Views: 417
Last edited by a moderator:
  • #5
weetabixharry said:
In this case, the minimum is at [itex]\frac{m}{x}=1.8865[/itex], which is closer to 1 than the optimal value 3. I could probably find more extreme failures, but the shape is generally something like this.

I was asking for the shape of f(x) (being a well-known shape), but if you know the shape of f(m/x), then that's good enough.

The broad shape of the graph is it starts at some value, it decreases until it reaches a minimum, and then increases until it reaches a final value.

So, if you know the graph has this overall shape and you know where the true minimum occurs, and you know which values of x are allowed, do you see how to combine that information?
 
  • #6
Hurkyl said:
So, if you know the graph has this overall shape and you know where the true minimum occurs, and you know which values of x are allowed, do you see how to combine that information?

I don't think I do. Perhaps it would be easier for me to think about [itex]f(x)[/itex] because that would be a parabola, which at least is symmetrical about the minimum...?
 
  • #7
No matter how I look at it, I can't see how to restrict the solution to the allowable discrete values (to give some sort of closed-form expression). Although I can evaluate any example numerically, doing that doesn't really give me much real insight into the nature of the problem.

Any more ideas?
 
  • #8
weetabixharry said:
No matter how I look at it, I can't see how to restrict the solution to the allowable discrete values (to give some sort of closed-form expression).
The solution has to be either the closest factor of m to the left of the minimum, or the closest one on the right. Which one can easily be distinguished by direct computation. Because of the geometry of the parabola, your original guess (nearest factor of m to the real minimum) is correct.
 
  • #9
Hurkyl said:
The solution has to be either the closest factor of m to the left of the minimum, or the closest one on the right. Which one can easily be distinguished by direct computation. Because of the geometry of the parabola, your original guess (nearest factor of m to the real minimum) is correct.

Of course... how stupid of me! I don't know how I missed that.

If the function to be minimised is not symmetrical about the minimum, then I guess I'd be in trouble (?)... but my problem here is straightforward.

Many thanks for the help!
 
  • #10
weetabixharry said:
If the function to be minimised is not symmetrical about the minimum, then I guess I'd be in trouble (?)
In this case, you can compare both function values there, as mentioned before. As long as you have the shape "falling, minimum, rising", this works. If there are additional minima and maxima hanging around, it can become tricky.
 
  • #11
mfb said:
In this case, you can compare both function values there, as mentioned before. As long as you have the shape "falling, minimum, rising", this works.

Yeah, I guess you know that one or the other must be the minimum... but I just feel that computing the values and comparing them seems a bit inelegant. I suppose I'm just used to the simple continuous case where I end up with a nice expression in [itex]x[/itex].

mfb said:
If there are additional minima and maxima hanging around, it can become tricky.
I've heard some talk about convex/non-convex optimisation. Is my problem a simple example of a convex problem?
 
  • #12
Harry you havd the right idea when you said that you should use the value of x as close as possible to [itex]x_{min}=\frac{mn-1}{2(n-1)}[/itex]

But you should have expressed it as,

[itex]\frac{m}{k}[/itex] as close as possible to [itex]\frac{mn-1}{2(n-1)}[/itex]

which gives,

[itex]\frac{1}{k}[/itex] as close as possible to [itex]\frac{mn-1}{2m(n-1)}[/itex]

Where "k" is one of the factors of "m".
 
  • #13
^ ... continued

So in your numerical example above. Instead of solving for possible values of "x" that made 27/x as close as possible to the ideal value of 1.8865. You should instead have been solving for the value of k (where x = 27/k) such that 1/k is as close as possible to 1/1.8865. This would lead you directly to k=3 rather than k=1.
 
  • #14
I would say that the minimum (for the constraints you gave us) should always occur when x = 1. I am not absolutely sure, but I'll show you what I did:

Suppose the minimum is [itex] k^2 [/itex]. Then we want the x for which

[itex] f(x) = (mn - 2(n-1)x - 1)^2 = k^2 [/itex].

Now all numbers are required to be positive integers so k must be an integer. (by the way, I put k^2 because the left side is a perfect square).

so [itex] mn - 2(n-1)x - 1 = ± k [/itex].

so [itex] x = \frac {1 - mn ± k} {2(1-n)} [/itex]

since x is a positive integer, 1 - mn ± k must be divisible by 2(1-n).
the smallest value of k for which 1 - mn + k is divisible by 2(1-n) is when 1 - mn + k = 2(1-n) (this is the smallest possible multiple of itself). so k = 2(1-n)-1+mn = 1 + mn - 2n.

This will be a positive integer whenever m ≥ 2 (and if m = 1 then x must be 1 anyways because x divides m). So x is 2(1-n) / 2(1 - n) = 1 which divides m.

(and so we can't use 1 - mn - k because in this case, x would be less than 1, but there are no positive integers less than 1).So the minimum respecting your constraints should always occur at x = 1
 
Last edited:
  • #15
weetabixharry said:
but I just feel that computing the values and comparing them seems a bit inelegant.
Think of it this way: it's a simple solution to a simple problem. And simple solutions are usually better than complicated solutions for any problem.

There is definitely value in considering alternative ways to solve problems, looking for new things to learn and new ideas that can be applied in general.

However, there is the danger of getting in the habit of being "too clever", and wind up making problems many, many times harder because you overlook a straightforward method.

Worse, it can even prevent you from solving problems: if you aren't in the habit of recognizing "oh, there are only two possibilities, I can just try them both out", then that will lead to a failure to look for -- or even recognize -- solutions to hard problems that begin with"do something clever to reduce the problem to one of two possibilities..."
 
  • #16
Boorglar said:
since x is a positive integer, 1 - mn ± k must be divisible by 2(1-n).
the smallest value of k for which 1 - mn + k is divisible by 2(1-n) is when 1 - mn + k = 2(1-n) (this is the smallest possible multiple of itself). so k = 2(1-n)-1+mn = 1 + mn - 2n.

This will be a positive integer whenever m ≥ 2 (and if m = 1 then x must be 1 anyways because x divides m). So x is 2(1-n) / 2(1 - n) = 1 which divides m.

(and so we can't use 1 - mn - k because in this case, x would be less than 1, but there are no positive integers less than 1).


So the minimum respecting your constraints should always occur at x = 1
You construct the minimal x, not the minimal k.
We already have counterexamples in the thread.
 
  • #17
oops I guess I messed up haha :P sorry for that

EDIT: ahhh forget it I think I see it. the denominator is 2(1-n) which is negative, so what I did was nonsense.
 
Last edited:

1. What is the purpose of minimising a function of integers?

The purpose of minimising a function of integers is to find the smallest possible value of the function within a given set of integers. This can be useful in various fields such as mathematics, computer science, and engineering, where finding the minimum value can help solve problems or optimize processes.

2. How do you determine the minimum value of a function of integers?

To determine the minimum value of a function of integers, you can use methods such as trial and error, graphing the function, or using calculus techniques such as differentiation. The specific method used will depend on the complexity and type of the function.

3. Can all functions of integers be minimised?

No, not all functions of integers can be minimised. Some functions may not have a minimum value or may have multiple minimum values. In some cases, the minimum value may be infinite.

4. Is there a difference between minimising a function of integers and minimising a function of real numbers?

Yes, there is a difference between minimising a function of integers and minimising a function of real numbers. Integers are whole numbers, while real numbers include fractions and irrational numbers. This means that the set of possible inputs for a function of integers is more limited, which can affect the methods used to minimise the function.

5. What are some applications of minimising a function of integers?

Minimising a function of integers has applications in various fields such as cryptography, game theory, and data compression. For example, in cryptography, minimising a function of integers can be used to generate secure encryption keys, while in game theory, it can help determine optimal strategies for players. In data compression, minimising a function of integers can be used to find the shortest representation of a set of data.

Similar threads

Replies
4
Views
411
Replies
4
Views
922
  • General Math
Replies
28
Views
4K
  • General Math
Replies
16
Views
2K
Replies
5
Views
877
Replies
6
Views
1K
Replies
10
Views
1K
  • General Math
Replies
10
Views
3K
Replies
4
Views
2K
Back
Top