Playing with operators

  • Thread starter dapet
  • Start date
  • Tags
    Operators
In summary, the conversation discusses finding the permutation of numbers 1 to 40 that results in the maximum value for the given expression, where the operators alternate regularly. It is mentioned that there may be more than one permutation that gives the same maximum value and that the generalization for 4n is also being considered. The suggested solution is based on the minimum and maximum values for certain permutations of (1,2,3,4,5,6), but the generalization and optimal positioning of numbers is still being explored. Assistance is requested in solving the problem.
  • #1
dapet
9
0
Determine the permutation (x_1,x_2,...,x_40) of numbers 1,2,...,40 such that the expression x_1 + x_2 / x_3 - x_4 * x_5 + x_6 / x_7 - x_8 * x_9 + ... + x_38 / x_39 - x_40
has the maximal possible value. (the operators +,/,-,* alternate regularly.) It can be generalized for 4n (where n is an arbitrary natural)?

But I must confess, that I have a lot of problems with the simpler task... I think that more than one permutation give the same maximum. I have one suggestion, but I can't prove that it belongs to the best of all.
It's based on:
let (a,b,c,d,e,f) be a permution of (1,2,3,4,5,6)
minimum of ab + cd + ef occurs for 6*1 + 2*5 + 3*4
maximum of a/b + c/d + e/f occrus for 6/1 + 5/2 + 4/3
But the generalization...

Thanks.
 
Physics news on Phys.org
  • #2
I think that the maximum looks like:
40+(39/20)+(38/21)+...(30/29)-(1*18)-(2*17)-...-(10*9)-19 and the generalization is (according to my opinion) similar... It's easy to prove that numbers 40,39,...,30 must be in numerators of fractions for reach the maximum, but I don't know how to prove that the "position" of other numbers as optimal as possible for reach the maximum...

Thanks for each help that I really need.
 
  • #3


Your approach seems to be on the right track. In fact, you have found a permutation that gives the maximum value for 6 terms, and this can be extended to any number of terms. For the generalization, we can use the same logic as you did for 6 terms, but we need to consider the pattern for 4n terms.

Let (a,b,c,d) be a permutation of (1,2,3,4)
Minimum of ab + cd occurs for 4*1 + 2*3
Maximum of a/b + c/d occurs for 4/1 + 3/2

So, for 8 terms, we have:
Minimum of ab + cd + ef + gh occurs for 4*(1+5) + 2*(3+7)
Maximum of a/b + c/d + e/f + g/h occurs for 4/(1+5) + 3/(3+7)

Similarly, for 12 terms, we have:
Minimum of ab + cd + ef + gh + ij + kl occurs for 4*(1+5+9) + 2*(3+7+11)
Maximum of a/b + c/d + e/f + g/h + i/j + k/l occurs for 4/(1+5+9) + 3/(3+7+11)

This pattern can be generalized for any number of terms, where the minimum will occur for the sum of the first n/2 terms and the maximum will occur for the sum of the first n/2 terms divided by the sum of the last n/2 terms.

So, for 40 terms, we have:
Minimum of ab + cd + ... + yz occurs for 4*(1+5+...+37) + 2*(3+7+...+39)
Maximum of a/b + c/d + ... + y/z occurs for 4/(1+5+...+37) + 3/(3+7+...+39)

This gives us a permutation of (1,2,...,40) that will give the maximum value for the given expression. However, as you mentioned, there may be multiple permutations that give the same maximum value. This can be proven using mathematical induction.

Therefore, the generalization for 4n terms holds true and your approach is correct.
 

1. What are operators in programming?

Operators in programming are symbols or keywords that perform specific tasks on operands, such as variables or values. They allow for mathematical calculations, logical comparisons, and other manipulations of data.

2. What are the different types of operators?

There are several types of operators in programming, including arithmetic operators (+, -, *, /), assignment operators (=, +=, -=), comparison operators (==, !=, <, >), logical operators (&&, ||, !), and more specialized operators for tasks like string concatenation and bitwise operations.

3. How do operators work in programming?

Operators work by taking one or more operands and performing a specific action on them. For example, the addition operator (+) takes two numeric operands and adds them together. The result of the operation is known as the "output" or "value" of the operator.

4. Can operators be used in all programming languages?

Yes, operators are a fundamental part of most programming languages and can be used in a variety of contexts. However, the specific operators available and their syntax may vary between languages.

5. What is operator precedence?

Operator precedence refers to the order in which operators are evaluated in an expression. This is important because it can affect the outcome of a calculation or comparison. For example, in the expression 10 + 5 * 2, the multiplication operator (*) has a higher precedence than the addition operator (+), so the multiplication will be performed first and the result will be 20.

Similar threads

Replies
3
Views
730
  • Linear and Abstract Algebra
Replies
7
Views
1K
  • Linear and Abstract Algebra
Replies
17
Views
1K
  • Linear and Abstract Algebra
Replies
1
Views
1K
  • Precalculus Mathematics Homework Help
Replies
32
Views
838
  • Topology and Analysis
Replies
8
Views
457
  • Set Theory, Logic, Probability, Statistics
Replies
6
Views
749
  • Linear and Abstract Algebra
Replies
4
Views
1K
  • Linear and Abstract Algebra
Replies
2
Views
1K
  • Linear and Abstract Algebra
Replies
7
Views
822
Back
Top