[Haskell-cafe] "Natural" polymorphism for n*(n+1)/2

Sebastiaan Joosten sjcjoosten+haskell at gmail.com
Wed Dec 16 23:31:33 UTC 2020


here's why it cannot be done:

data TwoByTwoMatrix = TTM Integer Integer Integer Integer

instance Num TwoByTwoMatrix where
  fromInteger i = TTM i 0 0 i
  (TTM a b c d) + (TTM e f g h) = TTM (a+e) (b+f) (c+g) (d+h)
  negate m = (fromInteger (-1)) * m
  (TTM a b c d) * (TTM e f g h) = TTM (b*g+a*e) (a*f+b*h) (d*g+c*e)
(c*f+d*h)
It should follow that the above is a (non-abelian) ring, as required (all
definitions follow the standard matrix addition/multiplication/addition
convensions).

n = (TTM 0 1 0 0)
then: n * (n + 1) = n.
Since n has odd entries, it cannot be divided by 2 (more precisely: we
cannot find an m s.t. n * 2 = m).

Best,
Sebastiaan


On Wed, Dec 16, 2020 at 6:14 PM Henning Thielemann <
lemming at henning-thielemann.de> wrote:

>
> On Wed, 16 Dec 2020, Tom Smeding wrote:
>
> > You say 'abs x = x/2', but what's that (/)? For example, what is 'abs'
> > supposed to give when called on (the representation of) the polynomial
> > X^2 + 3X + 2?
>
> I meant it this way:
>
> instance (Fractional a) => Num (Polynomial a) where
>     abs = fmap (/2)
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20201216/3951b214/attachment.html>


More information about the Haskell-Cafe mailing list