alt-romes / hegg

Fast equality saturation in Haskell
https://hackage.haskell.org/package/hegg
BSD 3-Clause "New" or "Revised" License
75 stars 8 forks source link

Add new tests for Jacobi elliptic function simplification. #22

Open NadiaYvette opened 1 year ago

NadiaYvette commented 1 year ago

This adds addition theorems, Pythagorean analogues, and derivatives where absent for cos, sin, cosh, sinh, and sn, cn, and dn in a new file in test/ -- Jacobi.hs derived from Sym.hs (mostly a copy with some new primops and rewrite rules).

alt-romes commented 1 year ago

This is great work! Thanks for doing it. A couple of comments

alt-romes commented 1 year ago

Looking good (modulo the squashing, no hurries though). How's the situation? Let me know if you need any help.

NadiaYvette commented 1 year ago

@alt-romes The squash will definitely be done, and maybe I should do one even before passing the tests. There's just a little trouble at the moment getting things to pass the tests. Achieving sum-of-products while collecting powers of variables in monomials is taking some thought to figure out how to deal with by using a cost function.

alt-romes commented 1 year ago

I see, that doesn't sound easy indeed! OK, good luck, ping me when you're ready, or stuck 😄

NadiaYvette commented 1 year ago

I see, that doesn't sound easy indeed! OK, good luck, ping me when you're ready, or stuck smile

@alt-romes It's probably safe to say that I'm a little stuck. The good news is that the rules seem to be involved enough to get testcases to spin for something like 45s.

alt-romes commented 1 year ago

Great @NadiaYvette! That's good for benchmarking and optimizing the library further.

I would argue that getting a cost function to arrive at a SOP simplification is not all that too important, not for the testsuite at least (it would be different if this were a symbolic maths library -- i'd like to do that some time in the image of Metatheory.jl, but in a separate project).

Is your problem only that the simplification doesn't end up exactly as the one you wrote for the test?

If so, I suggest you look at whatever it actually does rewrite the expressions too, and manually see if they are equivalent to the ones you were expecting, and if they were in fact simplified. If all is good, just write the thing it produces as the expected output -- even if that isn't exactly what you'd expect from a computer algebra system.