print(sqrt(-1)())
|
|
time: 0.817000ms stack: size: 9
|
simplifyAssertEq(sqrt(-1), i)
|
GOOD |
time: 0.674000ms stack: size: 9
|
| ||
make sure, when distributing sqrt()'s, that the negative signs on the inside are simplified in advance
| ||
simplifyAssertEq( ((((-x*a - x*b)))^frac(1,2)), i * (sqrt(x) * sqrt(a+b)) )
|
GOOD |
time: 10.220000ms stack: size: 16
|
simplifyAssertEq( (-(((-x*a - x*b)))^frac(1,2)), -i * (sqrt(x) * sqrt(a+b)) )
|
GOOD |
time: 9.515000ms stack: size: 21
|
| ||
simplifyAssertEq( ((((-x*a - x*b)*-1))^frac(1,2)), (sqrt(x) * sqrt(a+b)) )
|
GOOD |
time: 5.549000ms stack: size: 15
|
simplifyAssertEq( (-(((-x*a - x*b)*-1))^frac(1,2)), -(sqrt(x) * sqrt(a+b)) )
|
GOOD |
time: 5.671000ms stack: size: 20
|
If sqrt, -1, and mul factor run out of order then -sqrt(-x) and sqrt(-x) will end up equal. And that isn't good for things like solve() on quadratics.
| ||
simplifyAssertEq( ((((-x*a - x*b)/-1)/y)^frac(1,2)), (sqrt(x) * sqrt(a+b)) / sqrt(y) )
|
GOOD |
time: 14.229000ms stack: size: 35
|
simplifyAssertEq( (-(((-x*a - x*b)/-1)/y)^frac(1,2)), -(sqrt(x) * sqrt(a+b)) / sqrt(y) )
|
GOOD |
time: 13.795000ms stack: size: 41
|
| ||
| ||
simplifying expressions with sqrts in them
| ||
simplifyAssertEq( 2^frac(-1,2) + 2^frac(1,2), frac(3, sqrt(2)) )
|
GOOD |
time: 3.861000ms stack: size: 12
|
simplifyAssertEq( 2*2^frac(-1,2) + 2^frac(1,2), 2 * sqrt(2) )
|
GOOD |
time: 1.912000ms stack: size: 13
|
simplifyAssertEq( 4*2^frac(-1,2) + 2^frac(1,2), 3 * sqrt(2) )
|
GOOD |
time: 1.976000ms stack: size: 13
|
| ||
simplifyAssertEq( (1 + sqrt(3))^2 + (1 - sqrt(3))^2, 8 )
|
GOOD |
time: 6.228000ms stack: size: 7
|
| ||
simplifyAssertEq( (frac(1,2)*sqrt(3))*(frac(sqrt(2),sqrt(3))) + (-frac(1,2))*(frac(1,3)*-sqrt(2)) , 2 * sqrt(2) / 3)
|
GOOD |
time: 9.600000ms stack: size: 13
|
| ||
simplifyAssertEq( -frac(1,3)*-frac(1+sqrt(3),3) + -frac(2,3)*frac(1,3) + -frac(2,3) * frac(1-sqrt(3),3), -frac(1 - sqrt(3), 3))
|
GOOD |
time: 13.015000ms stack: size: 24
|
| ||
simplifyAssertEq( -sqrt(3)*sqrt(2)/(2*sqrt(3)) + sqrt(2)/6, -sqrt(2)/3 )
|
GOOD |
time: 4.790000ms stack: size: 17
|
| ||
simplifyAssertEq( 1 + 5*sqrt(5) + sqrt(5), 1 + 6*sqrt(5) )
|
GOOD |
time: 2.171000ms stack: size: 10
|
powers of the sqrt sometimes get caught simplifying as merging the exponents, and don't add.simplifyAssertEq( 1 + 25*sqrt(5) + sqrt(5), 1 + 26*sqrt(5) )
|
GOOD |
time: 2.123000ms stack: size: 10
|
simplifyAssertEq( 1 + 5*sqrt(5) - 5*sqrt(5), 1 )
|
GOOD |
time: 1.132000ms stack: size: 7
|
| ||
simplifyAssertEq( -(1 + sqrt(5))/(2*sqrt(3)) , frac(1,2)*(-frac(1,sqrt(3)))*(1 + sqrt(5)) )
|
GOOD |
time: 17.324000ms stack: size: 83
|
| ||
simplifyAssertEq( (-(1-sqrt(3))/3)*(frac(1,3)) + ((2+sqrt(3))/6)*(-(1-sqrt(3))/3) + (-(1+2*sqrt(3))/6)*(-(1+sqrt(3))/3) , (1 + sqrt(3))/3 )
|
GOOD |
time: 14.257000ms stack: size: 10
|
| ||
simplifyAssertEq( (-sqrt(sqrt(5) + 1) * (1 - sqrt(5))) / (4 * sqrt(sqrt(5) - 1)) , frac(1,2))
|
GOOD |
time: 10.615000ms stack: size: 7
|
| ||
ok this is hard to explain ..simplifyAssertNe( 6 + 6 * sqrt(3), 12)
|
GOOD |
time: 2.935000ms stack: size: 7
|
| ||
simplifyAssertEq( (sqrt(5) + 1) * (sqrt(5) - 1), 4)
|
GOOD |
time: 2.051000ms stack: size: 7
|
simplifyAssertEq( sqrt((sqrt(5) + 1) * (sqrt(5) - 1)), 2)
|
GOOD |
time: 2.512000ms stack: size: 7
|
| ||
simplifyAssertEq( (1 + 2 / sqrt(3)) / (2 * sqrt(3)), (2 + sqrt(3)) / 6 )
|
GOOD |
time: 6.311000ms stack: size: 10
|
| ||
simplifyAssertEq( (frac(1,3)*(-(1-sqrt(3)))) * (frac(1,3)*(-(1-sqrt(3)))) + (frac(1,6)*(2+sqrt(3))) * (frac(1,3)*(1+sqrt(3))) + (frac(1,6)*-(1+2*sqrt(3))) * frac(1,3), (4 - sqrt(3))/6 )
|
GOOD |
time: 13.332000ms stack: size: 11
|
| ||
simplifyAssertEq( 1/sqrt(6) + 1/sqrt(6), 2/sqrt(6) )
|
GOOD |
time: 2.362000ms stack: size: 23
|
| ||
simplifyAssertEq( (32 * sqrt(3) + 32 * sqrt(15)) / 384, (sqrt(3) + sqrt(15)) / 12 )
|
GOOD |
time: 31.563000ms stack: size: 17
|
| ||
simplifyAssertEq( sqrt(5)/(2*sqrt(3)), sqrt(15)/6 )
|
GOOD |
time: 6.134000ms stack: size: 111
|
| ||
simplifyAssertEq( -1/(2*sqrt(3)), -sqrt(frac(1,12)) )
|
GOOD |
time: 5.803000ms stack: size: 98
|
simplifyAssertNe( -sqrt(frac(1,12)), sqrt(frac(1,12)) )
|
GOOD |
time: 6.492000ms stack: size: 137
|
| ||
simplifyAssertEq( (sqrt(2)*sqrt(frac(1,3))) * -frac(1,3) + (-frac(1,2)) * (sqrt(2)/sqrt(3)) + (frac(1,2)*1/sqrt(3)) * (-sqrt(2)/3), -sqrt(2) / sqrt(3) )
|
GOOD |
time: 20.320000ms stack: size: 22
|
| ||
simplifyAssertEq( 1 + ( -(7 - 3*sqrt(5)) / (3*(3 - sqrt(5))) )*(1 + frac(1,2)), (1 + sqrt(5))/4 )
|
GOOD |
time: 5.219000ms stack: size: 10
|
| ||
simplifyAssertEq( (-(sqrt(5)-1)/2)/sqrt((-(sqrt(5)-1)/2)^2 + 1), -sqrt( (sqrt(5) - 1) / (2 * sqrt(5)) ))
|
GOOD |
time: 35.123000ms stack: size: 120
|
| ||
simplifyAssertEq(sqrt(frac(15,16)) * sqrt(frac(2,3)), sqrt(5)/(2*sqrt(2)))
|
GOOD |
time: 3.974000ms stack: size: 18
|
| ||
| ||
simplify() was introducing an unflattened mul where there originally was none
| ||
TODO NOTICE - if there's just sqrt(2)*sqrt(3) then the sqrts will merge ... so should they merge if that extra 2 is out front?
| ||
local expr = 2*sqrt(2)*sqrt(3) local sexpr = expr() printbr(Verbose(expr), '=', Verbose(sexpr)) simplifyAssertEq(expr,sexpr)
|
*[2, sqrt[2], sqrt[3]] = *[2, sqrt[2], sqrt[3]]
GOOD |
time: 1.748000ms stack: size: 20
|
| ||
| ||
these go bad when I don't have mul/Prune/combineMulOfLikePow_mulPowAdd
| ||
simplifyAssertEq( ( sqrt(f) * (g + f * sqrt(g)) )() , sqrt(f) * sqrt(g) * (sqrt(g) + f))
|
GOOD |
time: 9.469000ms stack: size: 21
|
simplifyAssertEq( ( sqrt(f) * (g + sqrt(g)) )() , sqrt(f) * sqrt(g) * (sqrt(g) + 1))
|
GOOD |
time: 5.059000ms stack: size: 23
|
| ||
| ||
hmm having constant factor and sqrt/pow simplification problems
| ||
workssimplifyAssertEq( sqrt(15) - sqrt(15), 0)
|
GOOD |
time: 0.666000ms stack: size: 7
|
workssimplifyAssertEq( sqrt(6) - sqrt(Constant(2)*3), 0)
|
GOOD |
time: 0.486000ms stack: size: 7
|
simplifyAssertEq( sqrt(6) - sqrt(2)*sqrt(3), 0)
|
GOOD |
time: 0.525000ms stack: size: 7
|
simplifyAssertEq( sqrt(15)/2 - sqrt(15)/2, 0)
|
GOOD |
time: 1.504000ms stack: size: 7
|
simplifyAssertEq( sqrt(6*x) - sqrt(2)*sqrt(3)*sqrt(x), 0)
|
GOOD |
time: 0.700000ms stack: size: 7
|
| ||
| ||
without the extra product our difference-of-squares picks up fine ...simplifyAssertEq( (3+sqrt(5)) * (3 - sqrt(5)), 4 )
|
GOOD |
time: 1.742000ms stack: size: 7
|
and it does recognize without the sqrts as a simplified form ...assertEq( (4 * sqrt(3+sqrt(5)))(), 4 * sqrt(3+sqrt(5)) )
|
GOOD |
time: 1.101000ms stack: size: 11
|
but with and extra product of a sqrt of a sum ... it doesn't ... in fact specifically because the sqrt(3+sqrt(5)) matches the non-sqrt (3+sqrt(5)), so the powers combine, and then we can't merge all the sqrts into one as we did beforesimplifyAssertEq( (3+sqrt(5)) * (3 - sqrt(5)) * sqrt(3+sqrt(5)) , 4 * sqrt(3+sqrt(5)))
|
expected found lhs stack Init *[+[3, sqrt[5]], +[3, unm(sqrt[5])], sqrt[+[3, sqrt[5]]]] ^:Prune:sqrtFix4 ^[5, /[1, 2]] sqrt:Prune:apply ^[5, /[1, 2]] ^:Prune:sqrtFix4 ^[5, /[1, 2]] sqrt:Prune:apply ^[5, /[1, 2]] unm:Prune:doubleNegative *[-1, ^[5, /[1, 2]]] ^:Prune:sqrtFix4 ^[5, /[1, 2]] sqrt:Prune:apply ^[5, /[1, 2]] sqrt:Prune:apply ^[+[3, ^[5, /[1, 2]]], /[1, 2]] +:Prune:combineConstants 3 +:Prune:factorOutDivs /[3, 2] +:Prune:combineConstants /[3, 2] *:Prune:combinePows *[^[+[3, ^[5, /[1, 2]]], /[3, 2]], +[3, *[-1, ^[5, /[1, 2]]]]] Prune *[^[+[3, ^[5, /[1, 2]]], /[3, 2]], +[3, *[-1, ^[5, /[1, 2]]]]] *:Expand:apply +[*[^[+[3, ^[5, /[1, 2]]], /[3, 2]], 3], *[^[+[3, ^[5, /[1, 2]]], /[3, 2]], *[-1, ^[5, /[1, 2]]]]] Expand +[*[^[+[3, ^[5, /[1, 2]]], /[3, 2]], 3], *[^[+[3, ^[5, /[1, 2]]], /[3, 2]], *[-1, ^[5, /[1, 2]]]]] ^:Prune:sqrtFix4 ^[5, /[1, 2]] ^:Prune:sqrtFix4 ^[5, /[1, 2]] ^:Prune:sqrtFix4 ^[5, /[1, 2]] *:Prune:flatten *[-1, ^[5, /[1, 2]], ^[+[3, ^[5, /[1, 2]]], /[3, 2]]] Prune +[*[3, ^[+[3, ^[5, /[1, 2]]], /[3, 2]]], *[-1, ^[5, /[1, 2]], ^[+[3, ^[5, /[1, 2]]], /[3, 2]]]] Factor *[^[+[3, ^[5, /[1, 2]]], /[3, 2]], +[3, *[-1, ^[5, /[1, 2]]]]] Prune *[^[+[3, ^[5, /[1, 2]]], /[3, 2]], +[3, *[-1, ^[5, /[1, 2]]]]] Tidy *[+[3, sqrt[5]], sqrt[+[3, sqrt[5]]], +[3, unm(sqrt[5])]] rhs stack Init *[4, sqrt[+[3, sqrt[5]]]] ^:Prune:sqrtFix4 ^[5, /[1, 2]] sqrt:Prune:apply ^[5, /[1, 2]] sqrt:Prune:apply ^[+[3, ^[5, /[1, 2]]], /[1, 2]] Prune *[4, ^[+[3, ^[5, /[1, 2]]], /[1, 2]]] Expand *[4, ^[+[3, ^[5, /[1, 2]]], /[1, 2]]] ^:Prune:sqrtFix4 ^[5, /[1, 2]] Prune *[4, ^[+[3, ^[5, /[1, 2]]], /[1, 2]]] Factor *[4, ^[+[3, ^[5, /[1, 2]]], /[1, 2]]] Prune *[4, ^[+[3, ^[5, /[1, 2]]], /[1, 2]]] Tidy *[4, sqrt[+[3, sqrt[5]]]] BAD /home/chris/Projects/lua/symmath/tests/unit/unit.lua:125: failed stack traceback: /home/chris/Projects/lua/symmath/tests/unit/unit.lua:246: in function [C]: in function 'error' /home/chris/Projects/lua/symmath/tests/unit/unit.lua:125: in function 'simplifyAssertEq' [string "simplifyAssertEq( (3+sqrt(5)) * (3 - sqrt(5))..."]:1: in main chunk /home/chris/Projects/lua/symmath/tests/unit/unit.lua:238: in function [C]: in function 'xpcall' /home/chris/Projects/lua/symmath/tests/unit/unit.lua:237: in function 'exec' sqrt.lua:120: in function 'cb' /home/chris/Projects/lua/ext/timer.lua:58: in function 'timer' sqrt.lua:9: in main chunk [C]: at 0x5cbe028e2380 |
time: 7.440000ms stack: size: 11
|
seesimplifyAssertEq( (3+sqrt(5)) * (3 - sqrt(5)) * sqrt(2+sqrt(5)) , 4 * sqrt(2+sqrt(5)))
|
GOOD |
time: 8.075000ms stack: size: 11
|
so I need to merge powers if the power is a fraction *and* the denominator matches
| ||
| ||
these are in simplification loops
| ||
| ||
start with -1 / ( (√√5 √(√5 - 1)) / √2 ) ... what mine gets now vs what mathematica gets
| ||
simplifyAssertEq( -1 / ( sqrt(sqrt(5) * (sqrt(5) - 1)) / sqrt(2) ), sqrt((5 + sqrt(5)) / 10))
|
expected found lhs stack Init /[-1, /[sqrt[*[sqrt[5], +[sqrt[5], unm(1)]]], sqrt[2]]] ^:Prune:sqrtFix4 ^[5, /[1, 2]] sqrt:Prune:apply ^[5, /[1, 2]] ^:Prune:sqrtFix4 ^[5, /[1, 2]] sqrt:Prune:apply ^[5, /[1, 2]] unm:Prune:doubleNegative -1 ^:Prune:sqrtFix4 ^[5, /[1, 2]] +:Prune:combineConstants +[-1, ^[5, /[1, 2]]] +:Prune:combineConstants 2 *:Prune:combinePows ^[/[1, 2], 2] ^:Prune:distributePow ^[5, ^[/[1, 2], 2]] ^:Prune:expandMulOfLikePow *[^[5, ^[/[1, 2], 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]] sqrt:Prune:apply *[^[5, ^[/[1, 2], 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]] ^:Prune:sqrtFix4 ^[2, /[1, 2]] sqrt:Prune:apply ^[2, /[1, 2]] ^:Prune:sqrtFix4 ^[5, /[1, 2]] unm:Prune:doubleNegative *[-1, ^[5, /[1, 2]]] ^:Prune:simplifyConstantPowers 1 ^:Prune:simplifyConstantPowers 1 *:Prune:apply 5 *:Prune:apply -5 unm:Prune:doubleNegative -5 +:Prune:combineConstants -4 unm:Prune:doubleNegative *[^[2, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]], +[-1, *[-1, ^[5, /[1, 2]]]]] unm:Prune:doubleNegative *[4, ^[5, ^[/[1, 2], 2]]] /:Prune:negOverNeg /[*[^[2, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]], +[-1, *[-1, ^[5, /[1, 2]]]]], *[4, ^[5, ^[/[1, 2], 2]]]] /:Prune:conjOfSqrtInDenom /[*[^[2, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]], +[-1, *[-1, ^[5, /[1, 2]]]]], *[4, ^[5, ^[/[1, 2], 2]]]] /:Prune:mulBySqrtConj /[*[^[2, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]], +[-1, *[-1, ^[5, /[1, 2]]]]], *[4, ^[5, ^[/[1, 2], 2]]]] /:Prune:qIsDiv /[*[^[2, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]], +[-1, *[-1, ^[5, /[1, 2]]]]], *[4, ^[5, ^[/[1, 2], 2]]]] Prune /[*[^[2, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]], +[-1, *[-1, ^[5, /[1, 2]]]]], *[4, ^[5, ^[/[1, 2], 2]]]] *:Expand:apply +[*[^[2, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]], -1], *[^[2, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]], *[-1, ^[5, /[1, 2]]]]] ^:Expand:integerPower *[1, 1] ^:Expand:integerPower *[2, 2] ^:Expand:frac /[*[1, 1], *[2, 2]] Expand /[+[*[^[2, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]], -1], *[^[2, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]], *[-1, ^[5, /[1, 2]]]]], *[4, ^[5, /[*[1, 1], *[2, 2]]]]] ^:Prune:sqrtFix4 ^[2, /[1, 2]] ^:Prune:sqrtFix4 ^[5, /[1, 2]] ^:Prune:sqrtFix4 ^[2, /[1, 2]] ^:Prune:sqrtFix4 ^[5, /[1, 2]] ^:Prune:sqrtFix4 ^[5, /[1, 2]] *:Prune:apply 10 *:Prune:combineMulOfLikePow_constants *[-1, ^[10, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]] *:Prune:flatten *[-1, ^[10, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]] *:Prune:apply 1 *:Prune:apply 4 Prune /[+[*[-1, ^[2, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]], *[-1, ^[10, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]]], *[4, ^[5, /[1, 4]]]] Factor /[*[-1, +[*[^[2, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]], *[^[10, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]]]], *[4, ^[5, /[1, 4]]]] Prune /[*[-1, +[*[^[2, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]], *[^[10, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]]]], *[4, ^[5, /[1, 4]]]] Expand /[+[*[-1, *[^[2, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]]], *[-1, *[^[10, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]]]], *[4, ^[5, /[1, 4]]]] Prune /[+[*[-1, ^[2, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]], *[-1, ^[10, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]]], *[4, ^[5, /[1, 4]]]] Factor /[*[-1, +[*[^[2, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]], *[^[10, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]]]], *[4, ^[5, /[1, 4]]]] Prune /[*[-1, +[*[^[2, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]], *[^[10, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]]]], *[4, ^[5, /[1, 4]]]] Tidy unm(/[+[*[sqrt[2], sqrt[+[unm(1), sqrt[5]]]], *[sqrt[10], sqrt[+[unm(1), sqrt[5]]]]], *[4, ^[5, /[1, 4]]]]) rhs stack Init sqrt[/[+[5, sqrt[5]], 10]] ^:Prune:sqrtFix4 ^[5, /[1, 2]] sqrt:Prune:apply ^[5, /[1, 2]] sqrt:Prune:apply ^[/[+[5, ^[5, /[1, 2]]], 10], /[1, 2]] Prune ^[/[+[5, ^[5, /[1, 2]]], 10], /[1, 2]] ^:Expand:frac /[^[+[5, ^[5, /[1, 2]]], /[1, 2]], ^[10, /[1, 2]]] Expand /[^[+[5, ^[5, /[1, 2]]], /[1, 2]], ^[10, /[1, 2]]] ^:Prune:sqrtFix4 ^[5, /[1, 2]] ^:Prune:sqrtFix4 ^[10, /[1, 2]] Prune /[^[+[5, ^[5, /[1, 2]]], /[1, 2]], ^[10, /[1, 2]]] Factor /[*[^[^[5, /[1, 2]], /[1, 2]], ^[+[1, ^[5, /[1, 2]]], /[1, 2]]], ^[10, /[1, 2]]] Prune /[^[+[1, ^[5, /[1, 2]]], /[1, 2]], *[^[2, /[1, 2]], ^[5, /[1, 4]]]] Expand /[^[+[1, ^[5, /[1, 2]]], /[1, 2]], *[^[2, /[1, 2]], ^[5, /[1, 4]]]] Prune /[^[+[1, ^[5, /[1, 2]]], /[1, 2]], *[^[2, /[1, 2]], ^[5, /[1, 4]]]] Factor /[^[+[1, ^[5, /[1, 2]]], /[1, 2]], *[^[2, /[1, 2]], ^[5, /[1, 4]]]] Prune /[^[+[1, ^[5, /[1, 2]]], /[1, 2]], *[^[2, /[1, 2]], ^[5, /[1, 4]]]] Tidy /[sqrt[+[1, sqrt[5]]], *[sqrt[2], ^[5, /[1, 4]]]] BAD /home/chris/Projects/lua/symmath/tests/unit/unit.lua:125: failed stack traceback: /home/chris/Projects/lua/symmath/tests/unit/unit.lua:246: in function [C]: in function 'error' /home/chris/Projects/lua/symmath/tests/unit/unit.lua:125: in function 'simplifyAssertEq' [string "simplifyAssertEq( -1 / ( sqrt(sqrt(5) * (sqrt..."]:1: in main chunk /home/chris/Projects/lua/symmath/tests/unit/unit.lua:238: in function [C]: in function 'xpcall' /home/chris/Projects/lua/symmath/tests/unit/unit.lua:237: in function 'exec' sqrt.lua:120: in function 'cb' /home/chris/Projects/lua/ext/timer.lua:58: in function 'timer' sqrt.lua:9: in main chunk [C]: at 0x5cbe028e2380 |
time: 20.274000ms stack: size: 17
|
simplifyAssertEq( -(sqrt( 10 * (sqrt(5) - 1) ) + sqrt(2 * (sqrt(5) - 1))) / (4 * sqrt(sqrt(5))), sqrt((5 + sqrt(5)) / 10))
|
expected found lhs stack Init /[unm(+[sqrt[*[10, +[sqrt[5], unm(1)]]], sqrt[*[2, +[sqrt[5], unm(1)]]]]), *[4, sqrt[sqrt[5]]]] ^:Prune:sqrtFix4 ^[5, /[1, 2]] sqrt:Prune:apply ^[5, /[1, 2]] unm:Prune:doubleNegative -1 ^:Prune:sqrtFix4 ^[5, /[1, 2]] +:Prune:combineConstants +[-1, ^[5, /[1, 2]]] ^:Prune:sqrtFix4 ^[10, /[1, 2]] ^:Prune:expandMulOfLikePow *[^[10, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]] sqrt:Prune:apply *[^[10, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]] ^:Prune:sqrtFix4 ^[5, /[1, 2]] sqrt:Prune:apply ^[5, /[1, 2]] unm:Prune:doubleNegative -1 ^:Prune:sqrtFix4 ^[5, /[1, 2]] +:Prune:combineConstants +[-1, ^[5, /[1, 2]]] ^:Prune:sqrtFix4 ^[2, /[1, 2]] ^:Prune:expandMulOfLikePow *[^[2, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]] sqrt:Prune:apply *[^[2, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]] unm:Prune:doubleNegative *[-1, +[*[^[10, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]], *[^[2, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]]]] ^:Prune:sqrtFix4 ^[5, /[1, 2]] sqrt:Prune:apply ^[5, /[1, 2]] +:Prune:combineConstants 2 *:Prune:combinePows ^[/[1, 2], 2] ^:Prune:distributePow ^[5, ^[/[1, 2], 2]] sqrt:Prune:apply ^[5, ^[/[1, 2], 2]] Prune /[*[-1, +[*[^[10, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]], *[^[2, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]]]], *[4, ^[5, ^[/[1, 2], 2]]]] *:Expand:apply +[*[-1, *[^[10, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]]], *[-1, *[^[2, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]]]] ^:Expand:integerPower *[1, 1] ^:Expand:integerPower *[2, 2] ^:Expand:frac /[*[1, 1], *[2, 2]] Expand /[+[*[-1, *[^[10, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]]], *[-1, *[^[2, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]]]], *[4, ^[5, /[*[1, 1], *[2, 2]]]]] ^:Prune:sqrtFix4 ^[10, /[1, 2]] ^:Prune:sqrtFix4 ^[5, /[1, 2]] *:Prune:flatten *[-1, ^[10, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]] ^:Prune:sqrtFix4 ^[2, /[1, 2]] ^:Prune:sqrtFix4 ^[5, /[1, 2]] *:Prune:flatten *[-1, ^[2, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]] *:Prune:apply 1 *:Prune:apply 4 Prune /[+[*[-1, ^[10, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]], *[-1, ^[2, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]]], *[4, ^[5, /[1, 4]]]] Factor /[*[-1, +[*[^[2, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]], *[^[10, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]]]], *[4, ^[5, /[1, 4]]]] Prune /[*[-1, +[*[^[2, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]], *[^[10, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]]]], *[4, ^[5, /[1, 4]]]] Expand /[+[*[-1, *[^[2, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]]], *[-1, *[^[10, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]]]], *[4, ^[5, /[1, 4]]]] Prune /[+[*[-1, ^[2, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]], *[-1, ^[10, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]]], *[4, ^[5, /[1, 4]]]] Factor /[*[-1, +[*[^[2, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]], *[^[10, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]]]], *[4, ^[5, /[1, 4]]]] Prune /[*[-1, +[*[^[2, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]], *[^[10, /[1, 2]], ^[+[-1, ^[5, /[1, 2]]], /[1, 2]]]]], *[4, ^[5, /[1, 4]]]] Tidy unm(/[+[*[sqrt[2], sqrt[+[unm(1), sqrt[5]]]], *[sqrt[10], sqrt[+[unm(1), sqrt[5]]]]], *[4, ^[5, /[1, 4]]]]) rhs stack Init sqrt[/[+[5, sqrt[5]], 10]] ^:Prune:sqrtFix4 ^[5, /[1, 2]] sqrt:Prune:apply ^[5, /[1, 2]] sqrt:Prune:apply ^[/[+[5, ^[5, /[1, 2]]], 10], /[1, 2]] Prune ^[/[+[5, ^[5, /[1, 2]]], 10], /[1, 2]] ^:Expand:frac /[^[+[5, ^[5, /[1, 2]]], /[1, 2]], ^[10, /[1, 2]]] Expand /[^[+[5, ^[5, /[1, 2]]], /[1, 2]], ^[10, /[1, 2]]] ^:Prune:sqrtFix4 ^[5, /[1, 2]] ^:Prune:sqrtFix4 ^[10, /[1, 2]] Prune /[^[+[5, ^[5, /[1, 2]]], /[1, 2]], ^[10, /[1, 2]]] Factor /[*[^[^[5, /[1, 2]], /[1, 2]], ^[+[1, ^[5, /[1, 2]]], /[1, 2]]], ^[10, /[1, 2]]] Prune /[^[+[1, ^[5, /[1, 2]]], /[1, 2]], *[^[2, /[1, 2]], ^[5, /[1, 4]]]] Expand /[^[+[1, ^[5, /[1, 2]]], /[1, 2]], *[^[2, /[1, 2]], ^[5, /[1, 4]]]] Prune /[^[+[1, ^[5, /[1, 2]]], /[1, 2]], *[^[2, /[1, 2]], ^[5, /[1, 4]]]] Factor /[^[+[1, ^[5, /[1, 2]]], /[1, 2]], *[^[2, /[1, 2]], ^[5, /[1, 4]]]] Prune /[^[+[1, ^[5, /[1, 2]]], /[1, 2]], *[^[2, /[1, 2]], ^[5, /[1, 4]]]] Tidy /[sqrt[+[1, sqrt[5]]], *[sqrt[2], ^[5, /[1, 4]]]] BAD /home/chris/Projects/lua/symmath/tests/unit/unit.lua:125: failed stack traceback: /home/chris/Projects/lua/symmath/tests/unit/unit.lua:246: in function [C]: in function 'error' /home/chris/Projects/lua/symmath/tests/unit/unit.lua:125: in function 'simplifyAssertEq' [string "simplifyAssertEq( -(sqrt( 10 * (sqrt(5) - 1) ..."]:1: in main chunk /home/chris/Projects/lua/symmath/tests/unit/unit.lua:238: in function [C]: in function 'xpcall' /home/chris/Projects/lua/symmath/tests/unit/unit.lua:237: in function 'exec' sqrt.lua:120: in function 'cb' /home/chris/Projects/lua/ext/timer.lua:58: in function 'timer' sqrt.lua:9: in main chunk [C]: at 0x5cbe028e2380 |
time: 23.423000ms stack: size: 17
|