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
--
Met vriendelijke groet,
@@i = Arie Groeneveld

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

--
Met vriendelijke groet,
@@i = Arie Groeneveld

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

Reply via email to