One of the joys of following this forum is that one, I for one, can learn a
lot about interesting topics besides J programming.

I was wondering if the original and the additional farmer’s problems and
solutions could be put in a common, more general framework.  Here are some
thoughts building on insights I got from reading this thread.

Granted assumption: (convex) regular polygons are perimeter-area optimal.
That is, they have (within the class of polygons with the same number of
segments) the largest area for a given perimeter, or in terms of its dual
problem, they have the smallest perimeter for a given area.

Imagine that, just for the sake of the argument, the farmer also wants to
make a covered chicken yard inside the barn using 100 extra meters of
fence.  Once the farmer finds the optimal rectangular shape for the outside
yard, the farmer can just reflect the shape along the barn’s wall to get
the blueprint for the optimal inside yard.  The farmer can now consider the
problem of making an entire optimal symmetric yard.

The original problem: the rectangular restriction means that the entire
yard must be also rectangular and its optimal shape must a square with the
segment of the wall being used lying on its axis of symmetry.  Thus, the
optimal shape for the outside yard must be a half square (with two 25
meters walls and one 50 meters wall having an optimal area of (1250 -: 25
*50)).

The additional problem (with a partial free shape): one can consider a
sequence of problems of making optimal yards using first 2, then 3, then
4,… straight segments.  Using a similar train of thoughts, the optimal
shape of the entire yard for the first problem in this sequence must be a
square with the segment of the wall along its diagonal, thus the optimal
shape of the outside yard must be a half square with a triangular shape
(with two equal segments at 45 degrees angles from the wall); for the
second problem the optimal entire shape must be a regular hexagon and the
shape of the optimal outside yard must be the half hexagon with 3 fence
segments; for the next problem the optimal shape of the outside yard must
be the half octagon with 4 fence segments, for the next, the optimal shape
of the outside yard must be the half decagon; and so on.

Using some trigonometry and algebra I found the following formula to
calculate the sequence of optimal areas with a perimeter of length 1:

area=. (1 % 4 * ]) * 3 o. (2 %~ o.1) * 1 - %

Thus, the optimal areas with a perimeter of length 100, for some instances,
must be:

   (*:100)&* @: area 2 3 5 100 1000 1000000 1000000000
1250 1443.37567 1538.84177 1591.41853 1591.54812 1591.54943 1591.54931
The semicircle optimal area must be:

   (*:100)&* @: area _
0
No, unfortunately J does not interpret the above sentence in that sense.
Never mind, 1 billion segments should suffice; what is the length of a
hydrogen atom?  Besides, the accuracy of the calculations seems to be
deteriorating at the end,

   (*:100)&* @: area 1000 1000000 1000000000
1591.54812 1591.54943 1591.54931

Let us jump one dimension up: now the farmer wants to make an area-volume
optimal separate container, to put all those eggs that are lying around, on
the flat surface of the farm.

If the container must be a rectangular polyhedron (that is, with four
rectangular walls and a flat roof) then the optimal rectangular polyhedron
must be a half cube (with four 2:1 rectangular walls and a square roof).

If the container must be a pyramid with four triangular walls then the
optimal pyramid with four triangular walls must be a half octahedron (with
regular triangular walls).

Is a half dodecahedron (or a half icosahedron) optimal?

The free-form container is a semi-sphere.

Let us jump one more dimension up: The free-form volume-hyper-volume
hyper-container lying on a flat space is the semi-hyper-sphere. (Is a half
hyper-cube the optimal rectangular hyper-container?)
I have to stop here; I am getting dizzy and do not know which of all the
statements above hold.


On Mon, Feb 25, 2013 at 10:18 AM, Aai <agroeneveld...@gmail.com> wrote:

> If we let the machine do the job I can offer a specialized verb:
>
> area=: [: (p. 1&{::@p.@p..) 0 1 +//.@(*/) _1r2,~-:
>
>
> ... and here's a verb that calculates the area of a circle segment
> depending on the cut off part off the circle
>
>
> SegmentArea=: ([: (-1&o.) 2p1%1+%) (1p1&*@*:@]-(*-:@*:)) 2p1 %~ +
>
> use:
>   (wire fence length) SegmentArea arc length cut off segment
>
>    SegmentArea~ 100
> 1591.55
>
>    >./ 100 SegmentArea 90+0.01*i.2000
> 1591.55
>
>    plot (;100&SegmentArea) 90+0.01*i.2000
>
>
>
>
>
> On 23-02-13 19:46, km wrote:
>
>> Can we have an adverb Max so that  f Max y  finds the maximum of  f  on
>> the list  y  ?
>>
>> Sent from my iPad
>>
>>
>> On Feb 23, 2013, at 12:03 PM, Aai <agroeneveld...@gmail.com> wrote:
>>
>>  With some math in J
>>>
>>> x : length barn side
>>> -->the other rectangle side is then
>>>   -: 100 - x
>>>
>>> i.o.w. we have
>>>   A =  x (50 - x/2)
>>>
>>> with J
>>>
>>>    0 1 +//.@(*/) 50 _0.5
>>> 0 50 _0.5
>>>
>>> first derivative
>>>
>>>    0 50 _0.5&p. d. 1
>>> 50 _1&p.
>>>
>>> second derivative
>>>
>>>    0 50 _0.5&p. d. 2
>>> _1"0
>>>
>>> --> a maximum for
>>>
>>>    1{:: p. 50 _1
>>> 50
>>>
>>> --> maximum (rectangular) area
>>>
>>>    0 50 _0.5&p. 50
>>> 1250
>>>
>>>
>>>
>>>
>>>
>>> On 23-02-13 15:42, km wrote:
>>>
>>>> Use J to solve the farmer's fence problem:
>>>>
>>>> A farmer with 100 meters of wire fence wants to make a rectangular
>>>> chicken yard using an existing barn wall for one of the north-south sides.
>>>>  What is the largest area he can enclose if he uses the 100 meters of fence
>>>> for the other three sides, and what are the dimensions of the largest-area
>>>> chicken yard?
>>>>
>>>> Kip Murray
>>>>
>>>> Sent from my iPad
>>>>
>>>> ------------------------------**------------------------------**
>>>> ----------
>>>> For information about J forums see http://www.jsoftware.com/**
>>>> forums.htm <http://www.jsoftware.com/forums.htm>
>>>>
>>> --
>>> Met vriendelijke groet,
>>> @@i = Arie Groeneveld
>>>
>>> ------------------------------**------------------------------**
>>> ----------
>>> For information about J forums see 
>>> http://www.jsoftware.com/**forums.htm<http://www.jsoftware.com/forums.htm>
>>>
>> ------------------------------**------------------------------**
>> ----------
>> For information about J forums see 
>> http://www.jsoftware.com/**forums.htm<http://www.jsoftware.com/forums.htm>
>>
>
> --
> Met vriendelijke groet,
> @@i = Arie Groeneveld
>
> ------------------------------**------------------------------**----------
> For information about J forums see 
> http://www.jsoftware.com/**forums.htm<http://www.jsoftware.com/forums.htm>
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to