summaryrefslogtreecommitdiff
path: root/macros/luatex/latex/luacas/tex/test/calculus/derivatives.lua
diff options
context:
space:
mode:
Diffstat (limited to 'macros/luatex/latex/luacas/tex/test/calculus/derivatives.lua')
-rw-r--r--macros/luatex/latex/luacas/tex/test/calculus/derivatives.lua30
1 files changed, 30 insertions, 0 deletions
diff --git a/macros/luatex/latex/luacas/tex/test/calculus/derivatives.lua b/macros/luatex/latex/luacas/tex/test/calculus/derivatives.lua
new file mode 100644
index 0000000000..5d5429f59b
--- /dev/null
+++ b/macros/luatex/latex/luacas/tex/test/calculus/derivatives.lua
@@ -0,0 +1,30 @@
+local a = DD(SymbolExpression("x") * SymbolExpression("y"), SymbolExpression("x"))
+local b = DD(Integer(3) * SymbolExpression("x") ^ Integer(2) + Integer(2) * SymbolExpression("x") + Integer(6), SymbolExpression("x"))
+local c = DD(E ^ SymbolExpression("x"), SymbolExpression("x"))
+local d = DD(FunctionExpression("f", {SymbolExpression("x") ^ Integer(2)}))
+local e = DD(SymbolExpression("x") ^ SymbolExpression("x"))
+local f = DD(PolynomialRing({Integer(3), Integer(4), Integer(5)}, "x"))
+local g = DD(LN(SymbolExpression("y")), SymbolExpression("y"))
+local h = DD(SymbolExpression("x") ^ SymbolExpression("n"))
+local i = DD(SIN((SymbolExpression("x"))))
+local j = DD(SIN(Integer(2) * COS(SymbolExpression("x"))))
+local k = DD(ARCTAN(SymbolExpression("x") ^ (Integer(1) / Integer(2))))
+local l = DD(ARCSEC(SymbolExpression("x")))
+
+starttest("derivatives")
+
+testeq(a, dparse("DD(x*y, x)"))
+testeq(a:autosimplify(), parse("y"), a)
+testeq(b:autosimplify(), parse("6 * x + 2"), b)
+testeq(c:autosimplify(), parse("e^x"), c)
+testeq(d:autosimplify(), (Integer(2) * SymbolExpression("x") * FunctionExpression("f", {SymbolExpression("x")^Integer(2)}, {Integer(1)})):autosimplify(), d)
+testeq(e:autosimplify(), parse("x^x * (1 + ln(x))"), e)
+testeq(f:autosimplify(), parse("4 + 10 * x"), f)
+testeq(g:autosimplify(), parse("y ^ -1"), g)
+testeq(h:autosimplify(), parse("n * x ^ (-1 + n)"), h)
+testeq(i:autosimplify(), parse("cos(x)"), i)
+testeq(j:autosimplify(), parse("-2 * cos(2 * cos(x)) * sin(x)"), j)
+testeq(k:autosimplify(), parse("1/2 * x^(-1/2) * (1+x) ^ -1"), k)
+testeq(l:autosimplify(), parse("abs(x)^-1 * (1 + -(x^2))^ (-1/2)"), l)
+
+endtest() \ No newline at end of file