On Sunday, June 3, 2018 at 9:56:01 PM UTC+10, Simon King wrote: > > On 2018-06-03, Simon King <simon...@uni-jena.de <javascript:>> wrote: > > Hi Travis, > > > > On 2018-06-03, Travis Scrimshaw <tsc...@ucdavis.edu <javascript:>> > wrote: > >> I am also generally in favor of having == being a (generally) fast > check. > >> However, the symbolics code takes the opposite approach: it has the > method > >> is_trivial_equal() for quick checks but == fires up the proof engine. > > > > No, that's not correct. > > > > For symbolics, "==" only does trivial checks > > That's not correct either. "==" apparently always returns an equation, > not a bool. > > Sorry, I was thinking of in the context of evaluating a boolean statement (such as "if x == y"). However, when checking the truth value of an expression, it does fire up the full engine:
sage: x = var('x') sage: f = sin(x)^2 + cos(x)^2 sage: f cos(x)^2 + sin(x)^2 sage: %timeit bool(f == 1) 10 loops, best of 3: 22.2 ms per loop sage: %timeit f.is_trivially_equal(1) The slowest run took 11394.28 times longer than the fastest. This could mean that an intermediate result is being cached. 1000000 loops, best of 3: 1.67 µs per loop sage: bool(f == 1) True sage: f.is_trivially_equal(1) False If it was doing something trivial, both outputs would be the same and there would be far less time taken to evaluate the bool. Best, Travis -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.