Comments (5)
@littleredcomputer , does this ring any bells?
from sicmutils.
from sicmutils.
Yes, @littleredcomputer another thing I noticed, and wasn't sure where to investigate, is that the simplifier sorts *
and +
calls in different order. Obviously we need to be careful here for non-commutative operations, but I know that there are many tests where we get different results (just a different order) if we don't use the hermetic-simplify-fixture
.
from sicmutils.
@littleredcomputer now that I've stared at some rules code, I see the same comment from Alexey (bubble sort!) in his "commutativity" code. He handles this by matching the entire list of arguments and sorting the whole thing at once.
https://github.com/axch/rules/blob/master/simplifiers.scm#L52
Can we do something similar, and match a full stack of partials? I think the original scmutils code has rules to:
- turn nests into products, handling partials that are exponentiated
- THEN sort the terms inside the product
But the latter is bubble-sorted, so we can still make it better.
Here's the scheme:
(def canonicalize-partials*
(ruleset
;; First turn nests into products.
((partial :i*) ((partial :j*) :f))
=>
((* (partial :i*) (partial :j*)) :f)
((partial :i*) ((* (partial :j*) :more*) :f))
=>
((* (partial :i*) (partial :j*) :more*) :f)
;; Exponentiation of operators makes things hairy
((expt (partial :i*) :n) ((partial :j*) :f))
=>
((* (expt (partial :i*) :n) (partial :j*)) :f)
((partial :i*) ((expt (partial :j*) :n) :f))
=>
((* (partial :i*) (expt (partial :j*) :n)) :f)
((expt (partial :i*) :n) ((expt (partial :j*) :m) :f))
=>
((* (expt (partial :i*) :n) (expt (partial :j*) :m)) :f)
;; Already some accumulation
((partial :i*) ((* (partial :j*) :more*) :f))
=>
((* (partial :i*) (partial :j*) :more*) :f)
((expt (partial :i*) :n) ((* (partial :j*) :more*) :f))
=>
((* (expt (partial :i*) :n) (partial :j*) :more*) :f)
((partial :i*) ((* (expt (partial :j*) :m) :more*) :f))
=>
((* (partial :i*) (expt (partial :j*) :m) :more*) :f)
((expt (partial :i*) :n) ((* (expt (partial :j*) :m) :more*) :f))
=>
((* (expt (partial :i*) :n) (expt (partial :j*) :m) :more*) :f)
;; Next sort products, if OK
#_#_#_(((* :xs* (partial :i*) :ys* (partial :j*) :zs*)
;; TODO check that this is waht we mean with symbol
(:? f symbol?))
:args*)
(let ((args (expression args)))
(and commute-partials?
(symb:elementary-access? i args)
(symb:elementary-access? j args)
(list< j i)))
(((* :xs* (partial :j*) :ys* (partial :i*) :zs*) :f)
:args*)
))
from sicmutils.
This seems to have... just fixed itself, as a result of some other twitches we've had in the codebase! #285 changes the series implementation and marks the close of this mystery bug.
from sicmutils.
Related Issues (20)
- Move over rest of files from simplify package
- How to use indexed sets HOT 2
- The README needs a minimal starting guide for a CLJS project. HOT 3
- ->infix isn't properly handling exponents. HOT 1
- Minor doc issues HOT 3
- Add clj-kondo config HOT 2
- Add define-coordinates, install-coordinates, uninstall-coordinates from FDG
- Port all remaining mechanics namespaces from scmutils HOT 1
- Implement abstract-{up,down,matrix} from scmutils
- port Stirling number implementation HOT 1
- add missing 2-tensor functions from structs.scm
- simplifier gets stuck for seemingly doable computation HOT 1
- util.permute functions encounter integer overflows HOT 5
- add moments monoid, fold to sicmutils.statistics.moments HOT 2
- Convert [?a ?x] patterns with VECTORS to match vectors only HOT 1
- Stack overflow error on simple rewrite HOT 4
- Simplification error with latest cljs HOT 1
- typo in simplify/rules.cljc HOT 2
- typo in sicmutils.simplify.rules/expand-multiangle HOT 1
- BigInt to number not allowed, SICM exercise 1.3 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sicmutils.