soegaard / racket-cas

Simple computer algebra system
60 stars 10 forks source link

(diff '(sqrt x) 'x) #25

Closed soegaard closed 2 years ago

soegaard commented 2 years ago

Fix.

soegaard commented 2 years ago

Not a bug. The operator diff expects a normalized expression and '(sqrt x) isn't.

Metaxal commented 2 years ago

Should I infer that you were caught yourself by this, or do you keep this closed issue for reference?

soegaard commented 2 years ago

Yep. I used diff in a project and forgot to normalize before calling it.

Metaxal commented 2 years ago

I was caught by this a couple of time in racket-cas too, and to a lesser degree in rascas, but in rascas at least you should always construct expressions with the normal operators, and never start from a quoted expression.

The downside is that the rascas operators replace the racket ones everywhere, which is often not what is wanted.

I think what I would really like is something more local like:

(with-rascas 
  (+ 'x 3)) ; works
(+ 'x 3) ; fails

Probably I should write a rascas/local module that doesn't dump/replace operators in the main namespace.