All Projects → MasonProtter → Symbolics.jl

MasonProtter / Symbolics.jl

Licence: MIT License
A symbolic math library written in Julia modelled off scmutils

Programming Languages

julia
2034 projects

Projects that are alternatives of or similar to Symbolics.jl

obake
A C++20 library for the symbolic manipulation of sparse polynomials & co.
Stars: ✭ 16 (-83.67%)
Mutual labels:  physics, computer-algebra-system
piranha
The Piranha computer algebra system.
Stars: ✭ 91 (-7.14%)
Mutual labels:  physics, computer-algebra-system
mathiu.cpp
mathiu : a simple computer algebra system in C++.
Stars: ✭ 58 (-40.82%)
Mutual labels:  computer-algebra-system, symbolic-math
SymbolicTensors.jl
Manipulate tensors symbolically in Julia! Currently needs a SymPy dependency, but work is ongoing to change the backend to SymbolicUtils.jl
Stars: ✭ 26 (-73.47%)
Mutual labels:  physics, symbolic-math
awesome-spectra
🌈 A collaborative list of awesome tools for spectroscopy. Also, check:
Stars: ✭ 47 (-52.04%)
Mutual labels:  physics
Atomic-Periodic-Table.Android
Atomic - Periodic Table
Stars: ✭ 33 (-66.33%)
Mutual labels:  physics
Yota.jl
Reverse-mode automatic differentiation in Julia
Stars: ✭ 113 (+15.31%)
Mutual labels:  automatic-differentiation
Nabla.jl
A operator overloading, tape-based, reverse-mode AD
Stars: ✭ 54 (-44.9%)
Mutual labels:  automatic-differentiation
elasty
A research-oriented elastic body simulator
Stars: ✭ 173 (+76.53%)
Mutual labels:  physics
D3D12Renderer
Custom renderer and physics engine written from scratch in C++/Direct3D 12.
Stars: ✭ 17 (-82.65%)
Mutual labels:  physics
use-ammojs
ammo.js physics for use with react-three-fiber
Stars: ✭ 16 (-83.67%)
Mutual labels:  physics
awesome-physics
🏄 A list of awesome resources I used to study Physics.
Stars: ✭ 27 (-72.45%)
Mutual labels:  physics
keisan
A Ruby-based expression parser, evaluator, and programming language
Stars: ✭ 48 (-51.02%)
Mutual labels:  symbolic-math
jitterphysics
A cross-platform, realtime physics engine for all .NET apps.
Stars: ✭ 327 (+233.67%)
Mutual labels:  physics
mathics-core
An open-source Mathematica. This repository contains the Python modules for WL Built-in functions, variables, core primitives, e.g. Symbol, a parser to create Expressions, and an evaluator to execute them.
Stars: ✭ 83 (-15.31%)
Mutual labels:  computer-algebra-system
voltar
WebGL only 2D game engine using Godot as the visual editor
Stars: ✭ 25 (-74.49%)
Mutual labels:  physics
continuum mechanics
Utilities for doing calculations in continuum mechanics.
Stars: ✭ 18 (-81.63%)
Mutual labels:  physics
DeepFlow
Pytorch implementation of "DeepFlow: History Matching in the Space of Deep Generative Models"
Stars: ✭ 24 (-75.51%)
Mutual labels:  automatic-differentiation
pytopomat
Python Topological Materials (pytopomat) is a code for easy, high-throughput analysis of topological materials.
Stars: ✭ 19 (-80.61%)
Mutual labels:  physics
MonteCarlo.jl
Classical and quantum Monte Carlo simulations in Julia
Stars: ✭ 125 (+27.55%)
Mutual labels:  physics

Build Status Build status codecov

Symbolics.jl

This is a package I'm throwing together after getting inspired by the talk Physics in Clojure which was about porting scmutils to clojure. scmutils is a Scheme package with a very interesting and powerful computer algebra system meant as a companion to the book Structure and Interpretation of Classical Mechanics.

My intention with Symbolics.jl is to attempt to recreate the functionality of scmutils in julia using julian syntax. The package is slowly morphing into some sort of hybrid between scmutils and Mathematica.

This package works on Julia 1.0. To add it, simply

pkg> add https://github.com/MasonProtter/Symbolics.jl

Note: This package is very much a work in progress! Don't rely on it for anything important.

Examples of use:

  1. Basic algebra
julia > using Symbolics

julia> @sym x y z t;

julia> x^2 + x^2
2 * x ^ 2
  1. You can replace symbols in expressions
julia> ex = 2x + x^2
2x + x^2

julia> ex(x => y)
2y + y^2
  1. functional composition
julia> f(x) = x^3;

julia> g(x) = x^2;

julia> f + g
(::#70) (generic function with 1 method)

julia> ans(x)
x ^ 3 + x ^ 2

julia> f * g
(::#72) (generic function with 1 method)

julia> ans(x)
x ^ 5
  1. (Automatic) symbolic differentiation, now with higher derivatives and no pertubration confusion!
julia> D(f+g)(x)
3 * x ^ 2 + 2x

julia> (D^2)(f+g)(x)
3 * (2x) + 2

julia> (D^3)(f+g)(x)
6

The derivative operator, D is of type Dtype <: Operator <: Function. The reason for this is because operations on functions should sometimes behave differently than operations on differential operators. Currently the only difference is in exponentiation, such that :^(f::Function, n) = x -> f(x)^n whereas :^(o::Operator,n::Integer) = x -> o(o( ... o(x))) where the operator o has been applied to x n times.

  1. Symbolic expressions are callable and can be differentiated
julia> D(x(t)^2 + 2x(t), t)
2 * (x)(t) * (D(x))(t) + 2 * (D(x))(t)

New: Generate the Euler Lagrange Equations from a Lagrangian

We can now define a Lagrangian, say that of a simple harmonic oscillator as

using Symbolics

@sym x m ω t

function L(local_tuple::UpTuple)
    t, q, qdot = local_tuple.data
   (0.5m)*qdot^2 - (0.5m*ω^2)*q^2
end

where the local_tuple is an object describing a time, posisition and velocity (ie. all the relevant phase space data). According to SICM, this data should be provided by a function Γ(w) where w defines a trajectory through space. Γ is defined as

Γ(w) = t -> UpTuple([t, w(t), D(w)(t)])

Hence, as shown in SICM, the Euler-Lagrange condition for stationary action may be written as the functional

Lagrange_Equations(L) = w -> D((3)(L)Γ(w)) - (2)(L)Γ(w)

where ∂(3) means partial derivative with respect to velocity and ∂(2) means partial derivative with respect to position (ie. the third and second elements of the local tuple respectively). Putting this all together, we may execute

julia> Lagrange_Equations(L)(x)(t)
(D(D(x)))(t) * m + (x)(t) * m * ω ^ 2

which when set equal to zero is the equation of motion for a simple harmonic oscillator, generated in pure Julia code code symbolically!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].