Skip to content

0.23.0: Mechanics code, prep for Emmy release

Latest
Compare
Choose a tag to compare
@sritchie sritchie released this 23 Jan 18:24
02e7a6e

This release adds a number of performance upgrades, and completes the port of all code in the mechanics package of the original scmutils library.

This will also be the final release before extracting most of the code in the library out and giving it a new identity and home as the "Emmy Computer Algebra System", housed at https://github.com/mentat-collective/emmy.

New Code / Upgrades

  • #531:

    • Adds proper self-require forms to all cljc namespaces with macros; this removes the need for :include-macros true or :refer-macros and makes the life of consumers simpler.

    • Upgrades sci, test.check, core.match, timbre, clojurescript, shadow-cljs dependencies to remove various warnings.

    • Adds sicmutils.structure/symbol-set

    • Adds IHash implementations for js/BigInt, goog.math.Long, goog.map.Integer and Ratio types

  • #514:

    • Modifies sicmutils.calculus.derivative/taylor-series to return a proper PowerSeries instance, which the user can call with some dx to get back the old behavior.

      The new version can take any number of arguments in addition to f.
      Supplying no arguments returns the expansion at 0; if you supply many
      arguments (totally fine!), you'll need to wrap your dx components in a
      vector before supplying them to the returned PowerSeries.

    • sicmutils.series/function-> works the same way now, and functions identically, but with a different implementation. (previously it took a single expansion point under a keyword argument :x0.)

    • The new sicmutils.calculus.derivative/symbolic-taylor-series is a port of Taylor-series-coefficients from scmutils. It has the same contract as taylor-series, except that the full expansion is performed symbolically, and the original arguments are substituted in after expansion and simplification.

    • Other changes:

      • Installs 1 as the one-like and identity-like return values for structures and vectors. A true identity element would be an identity element compatible with all entries of the structure; but as defined now, 1 is a fine choice and matches the scmutils implementation.

      • new sicmutils.differential/map-coefficients, which makes simplify slightly more efficient by filtering terms .

      • more efficient sicmutils.expression/variables-in, maybe 30% faster for big expressions; this makes a difference in the simplifier!

      • sicmutils.expression/substitute now works for proper Literal instances. Before it only worked for unwrapped literals.

      • matrix walks made slightly faster by caching a row or column before traversal

  • #512:

    • adds sicmutils.mechanics.routhian, with implementations of Lagrangian->Routhian, Routh-equations, Routhian->acceleration, Routhian->state-derivative, Lagrangian-state->Routhian-state and Routhian-state->Lagrangian-state.

    • adds missing sicmutils.mechanics.{routhian,time-evolution,noether} to sicmutils.env.sci

  • #509:

    • Fixes a bug with down*Matrix multiplication, and adds tests for correctness.

    • Adds sicmutils.matrix.{symmetric?,antisymmetric?} predicates

    • The mechanics port continues with sicmutils.mechanics.rigid:

      • T-rigid-body moves to T-body-Euler with an alias back to its original name. Same situation for Euler-state->L-body => L-body-Euler and Euler-state->L-space => L-space-Euler.

      • New functions: three-vector-components->antisymmetric, T-body, L-body, L-space, Euler->omega, Euler->omega-body, quaternion-state->omega-body, quaternion-state->omega-space, qw-state->L-body, qw-state->L-space, T-quaternion-state

  • #511 focuses on adding more rotations and efficiency to sicmutils.quaternion. Specifically:

    • magnitude-sq and magnitude are now more efficient.

    • New functions to get to and from quaternions and various matrix representations: from-rotation-matrix, ->rotation-matrix, from-complex-matrix, ->complex-matrix, from-4x4-matrix, ->4x4-matrix

    • New instances ONE-matrix, I-matrix, J-matrix, K-matrix, matrix representations of the corresponding quaternion elements.

    • Similar to the matrix elements, we also now have ONE-tensor, I-tensor, J-tensor, K-tensor.

  • #503:

    • adds sicmutils.mechanics.lagrange/Lagrangian for building function signatures of Lagrangians.

    • adds the sicmutils.mechanics.time-evolution namespace

    • adds sicmutils.mechanics.lagrange/L-axisymmetric-top, more efficient than the version in sicmutils.examples.top

    • Fleshes out sicmutils.mechanics.hamilton:

      • New functions: H-state?, compatible-H-state?, state->p, momenta, P, literal-Hamiltonian-state, L-state->H-state, H-state->L-state, H-state->matrix, matrix->H-state, make-Hamiltonian, D-phase-space, Hamiltonian->Lagrangian-procedure, Hamiltonian->Lagrangian, flow-derivative, flow-transform, standard-map-inverse, F->K, J-func, T-func, canonical-H?, canonical-K?, linear-function->multiplier, Phi, Phi*, qp-canonical?, polar-canonical-inverse, two-particle-center-of-mass , two-particle-center-of-mass-canonical, transpose-function, multiplicative-transpose, symplectic-two-form, canonical-transform?, J-matrix, symplectic?

      • F->CH moves to F->CT (F->CT is now an alias)

      • Legendre-transform-fn becomes Legendre-transform-procedure and gains more correctness tests, toggled on and off by the *validate-Legendre-transform?* dynamic variable.

  • #508 adds sicmutils.mechanics.noether namespace, with Noether-integral.

  • #506 tidies up the build by removing unneeded reader conditionals and replacing renames like core-= with a proper require of clojure.core.

  • #502 begins the port of the remaining items in the scmutils mechanics package over the Clojure. This PR focuses on sicmutils.mechanics.lagrange, which contains functions from many files in the original mechanics folder.

    • momentum-tuple moves here from sicmutils.mechanics.hamilton

    • New functions ->L-state, ->local, ->state,state->n-dof, time, state->{q,qdot,qddot}, coordinates, velocities, accelerations, Q, Qdot, Qdotdot, literal-Lagrangian-state path->state-path (alias for the existing Gamma), Rayleigh-dissipation, qv->local-path, Lagrange-equations-first-order, (with Lagrange-equations-1 alias), Lagrangian->power-loss, T3-spherical, L3-central, Dt-procedure and the wrapping operator Dt, Euler-lagrange-operator (with Lagrange-equations-operator and LE aliases), generalized-LE.

    • Many of these are aliased into sicmutils.env. Ask if you think more should be there!

    • many new built-in Lagrangians: L-Kepler-polar, L-coupled-harmonic, L-sliding-pend, L-pendulum, L-two-particle

    • Lagrange-equations, Lagrangian->acceleration, Lagrangian->state-derivative now take a dissipation function

    • local-state-derivative aliases the 1-arity version of Lagrangian->state-derivative

    • New rectangular->polar, polar->rectangular, spherical->rectangular and rectangular->spherical that operate on coordinates, with associated r->p (new), p->r, s->r and r->s (new).

  • #501 moves elliptic-integrals from sicmutils.special.elliptical-test sicmutils.special.elliptical, as it's needed by the upcoming sicmutils.mechanics.pendulum namespace.

Bug Fixes

  • #531:

    • Fixes a typo in one of the rules in sicmutils.simplify.rules/expand-multiangle, closing #530

    • Forces the subexpression walk in pattern.rule/try-subexpressions with doall

    • Adds type hints to all remaining Complex calls in js, to fix issues with advanced compilation (thanks to @mhuebert for finding this)

    • #515:

  • tidies up the square and cube speedups thanks to a tip from GJS

  • Converts more (mul x x) to square in the derivatives of the sicmutils.generic namespace.

  • fixes a bug in the numeric-zero? check of exponent's derivative.

  • #503:

    • Changes the default implementation of square and cube for differentials to use (expt <> 2) etc instead of (* <> <>).

      This is a big deal! For certain expressions there's a huge blowup when you square a big symbolic term, and taking the derivative of it TWICE is very messy.

      With this change, differentials use the chain rule to calculuate the derivative of $x^2$ as $2x*x'$, instead of using the product rule and achieving a SECOND differentiatation of the same form and another multiplication: $xx' + x'x$.

      Before a judicious simplify call I added, this change dropped the runtime of the sicmutils.sicm.ch3-test suite down by 6x. After the simplify change in sicmutils.examples.top the tests were still 40% faster in that namespace.

    • Fixes a bug where the RationalFunction cube implementation actually called square.

Misc

  • #532:

    • Removes the potemkin dependency by importing only what we need directly into sicmutils.util.def. This makes sense since our versions add a fork call so that they work for ClojureScript as well.

    • Moves all examples into the tests so that we don't ship them with the library. These will eventually be converted to Clerk notebooks.

    • Removes the hiccup dependency.

    • Upgrades test.chuck and removes all :include-macros true calls for that library. Only same/ish requires them now!

    • Capitalizes the "Script" in ClojureScript everywhere it appears.

  • #531:

    • Drops cljsjs dependencies in favor of deps.cljs entries