ProjectMOSAIC / mosaicCalc

Calculus in R
12 stars 4 forks source link

Mistakes in antiD? #13

Closed georgemsavva closed 2 years ago

georgemsavva commented 2 years ago

antiD seems to make mistakes with some analytic integrals. For example, this is incorrect:

> antiD( a*(1+x)~x )
function (x, C = 0, a) 
a * 1 * x + 1/2 * x^2 + C

Whereas multiplying out the LHS first gives the correct answer:

> antiD( a+a*x~x)
function (x, C = 0, a) 
a * x + a * 1/2 * x^2 + C

using mosaicCalc_0.5.1 R version 4.1.1 (2021-08-10) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19043)

dtkaplan commented 2 years ago

George, Thanks for opening this issue. I was able to fix the problem in the beta branch and all tests pass (including the new test I added for your case). Beta has some new functions that shouldn't affect you, and it's easier for me just to work with beta. If you see any problem when you do switch to beta, do let me know. I think the only one you might see is that D() gives sometimes more concise symbolic answers but which are mathematically equivalent to the ones generated by the CRAN version.

Install with

remotes::install_github("ProjectMOSAIC/mosaicCalc", ref="beta")