Borrowing ideas from Raul, I like
Max =: 1 : 0
max =. >./ u y
where =. max = u y
where # y ,. u y
)
which identifies the max and where it occurs:
*: Max i:2
_2 4
2 4
(4 - *:) Max i:2
0 4
Sent from my iPad
On Feb 23, 2013, at 1:04 PM, Jose Mario Quintana
<[email protected]> wrote:
> I did not see your second post!
>
> area=. ] * 50 - %&2
> area(max=. (>./) @:) 0 to 100
> 1250
> max
>> ./@:
>
> On Sat, Feb 23, 2013 at 1:46 PM, km <[email protected]> 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 <[email protected]> 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
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm