A school warm-up exercise to occupy your time

 

Not directly related to trading, but interesting. Warm-up for the brain and keyboard at the weekend :-) It came up when I was doing maths with my kids and trying to teach programming.

As you know, the area of a triangle can be calculated by the lengths of its three sides. For a polygon, alas, it is not so, but if you give lengths of sides, you can find the __maximal area__ of the figure with those sides.

Note a question: how it (maximal area of a polygon and angles adjacent to its sides) can be computed analytically and is the MT optimizer capable of such tricks ?

although this is rather just a curious problem for software solution, but may help with optimization: figure out what parameters to fix and within what limits to consider.

---

simply compare the area found by the optimizer's brute-force (and it will depend on the algorithm and what/how it is brute-force) and the analytical solution, which is the only one.

 

If there are more than three corners, connect all the corners with lines.

have some number of triangles

add up the areas of the triangles

any programming language
 
Renat Akhtyamov:

connect all the angles with lines. we have a number of triangles

add up the areas of the triangles

do the math :-)

side lengths 1-2-3-4-5-6, what is the maximal area of such a hexagon ?

 
Maxim Kuznetsov:

do the math :-)

side lengths 1-2-3-4-5-6, what is the maximum area of such a hexagon ?

I googled it, there are options.

I just don't want to bother.

 
Analytically, through the derivative
 
Maxim Kuznetsov:

do the math :-)

side lengths 1-2-3-4-5-6, what is the maximum area of such a hexagon ?

And how can it be maximum or minimum or whatever, if there is only one version of this hexagon? What does its area depend on?

Ah... a hexagon, not a triangle)

 

It looks like you need to inscribe it in a circle of the largest possible radius.

The area can be calculated using vector product or Gauss formula.

 
Aleksey Nikolayev:

It looks like you need to inscribe it in a circle of the largest possible radius.

The area can be calculated using vector product or Gauss formula.

Algorithmically, we just search for the angle, find the limit of change, search for it - and then recursively, choosing the maximum area. The accuracy and duration depends on the choice of angle at each step.

But the total duration is rather long to put it mildly.

If you shove it into some optimizer, it should converge faster

 
Maxim Kuznetsov:

Algorithmically, it's a simple search, take an angle, identify the limits of change, search - and then recursively, selecting the maximum area. The accuracy and duration depends on the choice of angle at each step.

But the total duration is rather long to put it mildly.

If you shove it into some optimizer, it should converge faster.

If we can write down the formula that determines the area, we'll use the derivative.

In general, it's a difficult task. Why?

 
Dmitry Fedoseev:

If you can write down the formula on which the area depends, then through the derivative.

For an N-facet with fixed lengths of sides, you must also know the angles between the N-3 sides. Then the area of the figure can be found. But the maximal possible area (for: sides known, angles arbitrary) is the only one

 
Maxim Kuznetsov:

For an N-facet with fixed side lengths, you also need to know the angles between the N-3 sides. Then we can find the area of a particular figure. But the maximal possible area (for: sides known, angles arbitrary) is the only one

in this case, yes, because we have to calculate as Alexey wrote above