| 1 |
local x = SymbolExpression("x") |
| 2 |
local ex = parse("e^x") |
| 3 |
local lnx = parse("ln(x)") |
| 4 |
|
| 5 |
local a = parse("y^2") |
| 6 |
local b = parse("x + y + 1") |
| 7 |
local c = parse("x*(y+1)+x+3*x*y^2") |
| 8 |
local d = parse("x^2+2*x*y+y^2+x") |
| 9 |
local e = parse("(x*y+x)^2+x^2") |
| 10 |
local f = parse("-x^2/e^x-2*x/e^x-2/e^x+x^2*e^x-2*x*e^x+2*e^x") |
| 11 |
local g = parse("x^(-2)+y*x^(-2)+z*x^2+2*x^2") |
| 12 |
local h = parse("a*ln(x)-ln(x)*x-x") |
| 13 |
|
| 14 |
|
| 15 |
starttest("collect method") |
| 16 |
|
| 17 |
testeq(a:collect(x), parse("y^2"), a) |
| 18 |
testeq(b:collect(x), parse("x + y + 1"), b) |
| 19 |
testeq(c:collect(x), parse("(3*y^2+y+2)*x"), c) |
| 20 |
testeq(d:collect(x), parse("x^2+(2*y+1)*x+y^2"), d) |
| 21 |
testeq(e:collect(x), parse("((y+1)^2+1)*x^2"), e) |
| 22 |
testeq(f:collect(ex), parse("(x^2-2*x+2)*e^x+(-x^2-2*x-2)/e^x"), f) |
| 23 |
testeq(g:collect(x), parse("(y+1)*x^(-2)+(z+2)*x^2"), g) |
| 24 |
testeq(h:collect(lnx), parse("(a-x)*ln(x)-x"), h) |
| 25 |
|
| 26 |
endtest() |