I'm sure you know the joke with the engineer, physicist, and
mathematician.  ``...the mathematician declares, as he cinches the fence
around himself, "I am on the outside."''

My heavy-handed approach to finding an optimal fence shape for a family
of curves produced a cubic equation with only slightly less area than
has the semi-circle.  There was far too much freedom so I limited the
starting simplex to specify cubics with large slope at 0 and slope of 0
at 30.

   load'math/misc/integrat'
   load'math/misc/amoeba' NB. amoeba is a no-fuss machine
   PathLengthIntegrand =: ((D.1)(%:@:>:@:*:@:))("0)
   PathLength =: adverb def '{. u PathLengthIntegrand integrate (0 , y)'

   Area =: adverb define  NB. y are the x argument for u
assert 0 = y u 0       NB. fence touches barn wall
Y =. (y&u PathLength)brent 10 44 1e_5 50
Y , {. y&u integrate (0 , Y)
)

   cubic =: (p.~ _4&{.)~  NB. assert 0 6 -: 1 2 3 cubic 0 1

   (-@:{:@:(cubic Area) amoeba (<10)) ([smoutput) 10 1 0(+"1)(+:1 0.3
0.003)(*"1)_0.5+(4 3 ?@$0)
9.95841 0.801499 _2.81907e_5
9.72548 0.890004  0.00178511
10.4916 0.735899 0.000975512
10.4528  1.09534  0.00092074
+----------------------------+-------+
|3.67092 _0.154143 0.00215239|_771.87|
+----------------------------+-------+

   NB. Area of semi-circle
   R=:100p_1
   -:o. *:R
1591.55

   +:771.87  NB. area of this optimized cubic 
1543.74


Imagine yourself in flatland.  PIN one end of the fence to the barn
wall, PIN the other side to a slider on the wall.  Now inflate the fence
through the tiny hole in the barn wall.  The pressure is uniform,
therefor the fence curvature is constant, balancing the force.
Therefore the fence is circular.  But, is it a semi-circle or is the
chord not a diameter?  I just realized the slider will move until
there's no tangential force, and the shape is a semi-circle.  That's
proof enough for me.  The following code verifies this.

Verb  area  below is the area of a circle beyond the chord.

   NB. tacit variable is phi, measured as
   NB. angle of incidence as if barn wall
   NB. is a mirror.
   NB. phi = 0 represents semi-circular fence

   S=: 100 NB. length of fence
   TAU=: 2p1
   sin=: 1&o.      
   cos=: 2&o.
   theta=: (TAU%4)&-
   r=: S % +:@:theta
   NB. area of circle 
   a=: area =: *:@:r * theta - sin * cos

   (a d. 1) 0  NB. extreme value at phi = 0
1.92358e_10
   (a d. 2) 0  NB. concave down, thus maximal.
_1290.06

-------------------------------------
Reference
Date: Sat, 23 Feb 2013 19:30:51 -0500
From: Henry Rich <henryhr...@nc.rr.com>
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] The farmer's fence
Message-ID: <51295f3b.5000...@nc.rr.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to