M2
M2 copied to clipboard
try fails to catch alarm
There are already existing open issues with alarm, this I think is a new one:
i1 : try (alarm 1; sleep 15;) else <<"should end up here (and does)"<<endl;
should end up here (and does)
i2 : try (alarm 1; sleep 15) else <<"should end up here (and doesn't)"<<endl;
stdio:2:51:(3): error: alarm occurred
This issue is presumably related to tail call optimisation (?). Note that I already submitted a PR a while ago about tail call, namely https://github.com/Macaulay2/M2/pull/3144, but it does not impact the issue described above.
I traced the issue to two different places that alarm is triggered, both in evaluate.d, namely evalraw in the first case, evalexcept in the second. I could try to fix something but first I would need to understand better the difference between these two functions. Note that evalraw has this comment
if test(exceptionFlag) && !steppingFurther(c) then ( -- compare this code to the code in evalexcept() below
presumably suggesting I should notice something that I don't...
Bugs that are harder to fix
\frac{0}{1-1}and\frac{1-1}{0}(\frac{0}{0}works)2(x+h)^2-2x^2((x+h)^2-x^2and2(x+h)(x+h)-x^2work)\frac{\pi+1}{\pi+1}(\frac{\pi}{\pi}works)\frac{x^2}{5x^2}(\frac{5x^2}{x^2}works)(-1)^{3/5}(should be-1noti)\frac{\frac{1}{x^6}}{\frac{1}{y^4}}becomes\frac{y^4}{x^6}(good) but\left(\frac{x^3}{y^2}\right)^{-2}becomes\frac{\frac{1}{x^6}}{\frac{1}{y^4}}(should be\frac{y^4}{x^6})exp(x)exp(2)(e^xe^2works)\frac{x+1-1+1}{x+1}(\frac{x+1-1+1}{x} works)(-2x)^{3/5}xsimplifies to(i)\sqrt{2}x^{8/5}not-2^{3/5}x^{8/5}((2x)^{3/5}xworks)(x^3y^2)^2((x^3)^2(y^2)^2and\left(\frac{x^3}{y^2}\right)^2work)\frac{2\sqrt{3}}{\sqrt{3}}becomes 2 (good) but\frac{\sqrt{12x}}{\sqrt{3x}}becomes\frac{2\sqrt{3}}{\sqrt{3}}\sqrt{12}(\frac{\sqrt{12x}}{\sqrt{x}}works)\sqrt{x^2y}\sqrt{x^2},\sqrt[4]{x^4}(missing absolute value)\sqrt[4]{x^6}(missing absolute value inside of root)
Logs
log(e^xy)(ln(e^xy)works)ln(\frac{x}{y})(log(\frac{x}{y})works)log(xy)-log(x)-log(y)(ln(xy)-ln(x)-ln(y)works)log(1)(ln(1)works)log(e)(ln(e)works)exp(log(x))exp(clog(x))exp(log(x)+y)exp(log(x)-y)log(exp(x))(ln(exp(x))works)\log(\sqrt{2})and\ln(\sqrt{2})(\log(\sqrt{x})and\ln(\sqrt{x})work)
Negative Signs
(-x)(-6)-\frac{-1}{x}(\frac{-1}{-x}works)(-x)^2((-2x)^2works)
Properties of Exponents
2xx(xxworks)\frac{e^x}{e}\frac{e}{e^x}e^xeande^xe^1(e^xe^2works)\left(\frac{1}{x}\right)^{-1}
Other Powers
0^00^\pi(0^{3.1}works)
Infinity
\infty^0\infty(1-1)(\infty(0)works)1^\infty-\infty(-2)and\infty(-2)(-\infty(2)and\infty(2)work)\frac{\infty}{2}\frac{\infty}{\infty}\frac{\infty}{\infty^{-2}}
Miscellaneous
\frac{1}{0}
Trig
sec(-x)is1/cos(x)but I believesec(x)is nicer- Similarly for
csc(pi+x),tan(pi/2-x),sec(pi/2-x),csc(pi/2-x) cot(pi+x)is supposed to becot(x)but set to-cot(x)tan(-x)cot(x)becomes-tan(x)cot(x)andtan(x)cot(x)becomes1buttan(-x)cot(x)doesn't become-1sin^2(x)is simplified to1/2(1-cos(2x))but2sin^2(x)is not simplified at allsin(x)cos(x)is simplified tosin(2x)/2but2sin(x)cos(x)is not simplified at all