Ah, yeah... This was just something I happened to have lying around,
and I didn't actually set out to write the quadratic formula.

That file came out of a discussion where someone asked the following
questions:

1. There are two arrays, (N and M) that contain the same numbers,
except in different (random) orders, and one of the arrays (let's say M)
contains one extra value. The extra value can be isolated in O(n) time. How?

2. Same setup, but now M contains /two/ extra values. These values can
still be isolated in O(n) time. How?

I guess I've already kind of spoiled it at this point, so I'll just say the
answer
to the second problem involves a quadratic equation. (Or at least my answer
did.)

I knew I could probably solve it directly in J using 'p.' but I was
learning about
proofs and wanted to brush up on my long forgotten algebra, so I figured I'd
try deriving the quadratic formula myself in J.

I did some of the work interactively in the j console, but I think I also
did quite
a bit just by re-arranging lines in my text editor, using the notation. Now
that
I think about it, I wouldn't be surprised if I never actually ran the code.

Nonetheless, It was actually a really interesting exercise, and I remember
finding myself noticing relationships that I'd never picked up on before in
conventional notation. Two of them are noted in the comments
with the symbol '<-->':

(-:x % y) <--> (x % +:y)
4**:x <--> *:+:x

They're both kind of obvious things everybody knows, but for
some reason they kind of jumped out at me using the notation.

Like... The first rule would be (2 * x / y ) <--> ( x / y / 2 )
and that just doesn't seem nearly as interesting to me as
the visual symmetry when you write it with -: and +: .

In the second one, I remember thinking how ugly the 4**:x looked when all
crammed together, and when I realized you could move (4*]) from the left
side of *: and get +: I kind of felt like J had taught me something I never
knew that I knew about math. :)

Anyway... Consider that file a very rough draft. Perhaps I will clean it up
and
post it to the wiki next time I'm feeling mathematical. :)

-Michal



On Mon, Mar 3, 2014 at 1:06 AM, Raul Miller <[email protected]> wrote:

> I have not read the full proof, yet, but I see a flaw:
>
> a1 =: _100 + rnd 27 $ 200
>
> This should be
>
> a1 =: _100 + 27 rnd 200
>
> Otherwise you might have multiple values that are the same in a1, and
> if one of those is selected by ij that violates your condition b1
> (this happens when you assign a value to 't').
>
> Also, I do not understand what n and m represent, so I had to stop
> reading the proof when I got to that point.
>
> Thanks,
>
> --
> Raul
>
>
> On Mon, Mar 3, 2014 at 12:40 AM, Michal Wallace
> <[email protected]> wrote:
> > ( I think this got marked as spam yesterday because I used HTML
> formatting,
> > so I'm trying again.
> > There was a longer transcript of a j session using the logic stuff. I'll
> > repost that on the programming list. )
> >
> > Here's a derivation of the quadratic formula in J.
> >
> >
> https://github.com/tangentstorm/tangentlabs/blob/master/j/quadratic.ijs#L132
> >
> > I also use this quite a bit on IRC:
> >
> > https://github.com/tangentstorm/tangentlabs/blob/master/j/logic.ijs
> >
> > The majority of the lines in those files are just assertions, using a
> > slightly modified version of the 'assert' verb in the z locale.
> > A large portion of the lines are in fact identities.
> > ----------------------------------------------------------------------
> > 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

Reply via email to