Tuesday, December 29, 2015

increasing flexibility of the Physics Derivation Graph

Currently the Physics Derivation Graph is designed as though there is a single authoritative user/developer (historically me). Having additional contributors is new, and contributors (including me) don't always provide valid content.

The following are ideas for a significant re-design of the Physics Derivation Graph

Independent Graphs per Derivation

Suppose every derivation was an independent graph. This is easier to debug and analyze. A set of these derivations could be then merged to analyze the full graph, but that shouldn't be a requirement. Merging derivation graphs incurs overhead of finding overlaps. The overlap would be identifying common expressions. For example,
A/B = C
is the same as
\frac{A}{B} = C
These should have the same unique index. This index (the Godel number) should be unique across all derivations. Although the graph of the derivation is independent of other derivations, the expression database will need to be shared globally.

Enable arbitrary formats

Currently all expressions are stored as Latex in a single CSV. I don't actually care about the representation (in this case Latex). Instead, I want a single numeric index (the Godel number) associated with arbitrary but equivalent representations. For example,
A/B = C
gets the same unique numeric index as
\frac{A}{B} = C
and a Sage representation is also acceptable:
A,B,C = var('A,B,C')
expr = A/B == C

To enable arbitrary formats, place each in a separate file with the naming convention
<unique numeric id>_<type>_<date>.<extension>
"Type" = {Latex, Mathematica, Sage, etc}
The date is to distinguish versions of the same expression, ie A/B = C versus \frac{A}{B} = C.
A single unique numeric index may have multiple files:
4924829_latex_20151228.tex
4924829_latex_20151229.tex
4924829_mathematica_20151228.nb

The reason to have separate files for each representation and for each expression is to increase flexibility. 
This adds to confusion when building the graph: which of the two equivalent latex representations should be used?
An additional source of work: checking that the various representations are consistent. An abstract syntax tree should be able to determine the equivalence of representations.

Implementing Inference Rules

Similarly for inference rule representations, there are Latex, Sage, and Mathematica implementations. Currently I have a single CSV for all the inference rules in Latex. Implement each inference rule in the relevant language:
multiplyBothSidesBy_latex_20151228.tex
multiplyBothSidesBy_sage_20151228.sagews
multiplyBothSidesBy_mathematica_20151228.nb

Again, there may be multiple ways to implement an inference rule. Which should be used when checking with the Computer Algebra System?
The inference rule representations might not be synchronized. This would be detectable if the derivation checks out using one CAS and not another. 

Friday, December 25, 2015

Sage as a candidate Computer Algebra System for the Physics Derivation Graph

I was excited to use Sage's online notebook interface to see whether it could handle the variety of expressions and inference rules in the Physics Derivation Graph.

I found a few unexpected behaviors. There's good support for many of the inference rules. When I tried to apply Sage to more advanced uses, either I don't understand the math well enough, or support in Sage doesn't exist.

Expectation value doesn't render Latex

Expectation values are used in the variance relation identity. I was impressed by the ability of Sage to use Expectation value from SymPy.
x=var('x')
from sympy.stats import E # expectation value
expr1=E((x-E(x))^2)==E(x^2)-(E(x))^2
expr2=E(x^2-2*x*E(x)+E(x)^2)==E(x^2)-(E(x))^2
print(bool(expr1.lhs() == expr2.lhs()))
expr3=E(x^2)-2*E(x)*E(x)+E(x)^2==E(x^2)-(E(x))^2
print(bool(expr3.lhs() == expr2.lhs()))
True
True

However, I wasn't able to display the content in LaTeX:
print(latex(expr3))
0 == 0

This is unfortunate but not a blocker

Real Part of Expression isn't what I was expecting

Sage doesn't produce the output I expected from .real_part() 

forget()
x=var('x')
assume(x,'real')
this=cos(x) + I*sin(x)
this.real_part()
cos(real_part(x))*cosh(imag_part(x)) - cos(real_part(x))*sinh(imag_part(x))

What I was looking for was that this.real_part() would return cos(x); similarly this.imag_part() should return sin(x).

Symbolic Levi-Civita not supported in Sage?

A Levi-Civita operator can be defined
levicivita = SymmetricGroup(3)
levicivita([1,2,3]).sign()
1

However, I can't use symbols as arguments
forget()
h,j,k=var('h,j,k')
assume(h,'integer')
assume(j,'integer')
assume(k,'integer')
levicivita = SymmetricGroup(3)
levicivita([j,k,m]).sign()
Invalid permutation vector: [h,j, k]

Del (aka Nabla) lacks symbolic support in Sage?

Symbolic cross-products work as desired
h,j,k=var('h,j,k')
m,n,p=var('m,n,p')
E = vector(SR, [h,j,k])
F = vector(SR, [m,n,p])
print(E.cross_product(F))
(-k*n + j*p, k*m - h*p, -j*m + h*n)

Other vector calculus operations appear to lack support for symbolic manipulation
https://en.wikipedia.org/wiki/Del#Gradient
https://en.wikipedia.org/wiki/Del#Divergence
https://en.wikipedia.org/wiki/Del#Curl

I don't quite understand what's being done with the following:
forget()
V = VectorSpace(SR,3)
h,j,k=var('h,j,k')
m,n,p=var('m,n,p')
E = vector(SR, [h,j,k])
print(E.curl([1,2,3]))
print(E.div([1,2,3]))
(0, -1, 1)
1


I want to be able to do Math with Latex as Input

Now that I'm using EquationMap for Latex input, the interface problem is effectively solved. Prior to that I developed the d3js-based web browser visualization of the Physics Derivation Graph. The remaining tasks are content entry and checking the graph using a Computer Algebra System (CAS).

The goal would be to enter a derivation (ie the quadratic equation) in Latex via EquationMap.com, then have Sage check the resulting graph for correctness.

Although I could do the content entry, I felt there wasn't a point to entering content in a format that isn't amenable to checking with a CAS. Ideally, I want a format that is easy to enter manually, and universally exportable (ie to Maple, Mathematica, Sage, SymPy).

I stumbled upon "Extracting Mathematical Semantics from LATEX Documents" which converts LaTeX math into Abstract Syntax Trees as the universal structure.

The idea of using Latex as the method of entry for mathematical calculations is a common objective, though no one has solved it.

Wednesday, December 16, 2015

relations between famous physics equations

Update 20190728: this content has been copied to this page

The Einstein and the Navier-Stokes Equations: Connecting the Two by Bredberg, Irene, Ph.D., HARVARD UNIVERSITY, 2012, 132 pages; 3513905
Abstract: This thesis establishes a precise mathematical connection between the Einstein equations of general relativity and the incompressible Navier-Stokes equation of fluid dynamics.
see also http://arxiv.org/abs/1101.2451

Relation between uncertainty and the quantum harmonic oscillator
http://hyperphysics.phy-astr.gsu.edu/hbase/quantum/hosc4.html
https://www.eng.fsu.edu/~dommelen/quantum/style_a/nt_uprl.html
http://hitoshi.berkeley.edu/221a/coherentstate.pdf

Schrodinger equation and quantum harmonic oscillator
http://homepage.univie.ac.at/reinhold.bertlmann/pdfs/T2_Skript_Ch_5.pdf

Schrodinger equation and wave equation
http://physics.stackexchange.com/questions/75363/how-is-the-schroedinger-equation-a-wave-equation
http://www.tcm.phy.cam.ac.uk/~bds10/aqp/handout_foundations.pdf

Friday, December 11, 2015

building content for the Physics Derivation Graph

Update 20190728: this content has been copied to this page.

I've decided to focus on building content for the Physics Derivation Graph. Since I don't think it's reasonable to enter all the mathematical physics content manually on my own, in this post I'll define some bounds.

There are expressions, domains, and notations that need to be included to demonstrate the comprehensive nature of the project and the capability of the framework.


ExpressionsDomainsNotation
Schrodinger's equationQuantumDirac/bra-ket

integration
Maxwell's equationsElectromagneticsdifferentiation
contravariant/covariantElectrodynamics
Navier StokesFluid Mechanics
mass-energy relation
Special Relativity
Thermodynamics
Uncertainty relationQuantum Mechanics
energy conservationclassical mechanics
string theory
wave equation
statistical mechanics
aerodynamics
simple harmonic oscillator

Other comprehensive lists of "things to know" in Physics






I'm stuck -- I don't know how to proceed

Current status:
I've written a translator that takes exported .tex files from EquationMap.com and converts the output to syntax for the Physics Derivation Graph. This effectively "solves" the interface problem for me, but not anyone else. That is, if someone else wanted to provide content for the PDG, they could use EquationMap, but then they'd need to submit the content to me. That clearly doesn't scale. However, I don't have a huge number of contributors to contend with.

Given that I have a user input interface, that leaves a few major tasks:
  • building content
  • checking content using a CAS
  • talk to potential users

I don't know how to deal with the CAS, as Mathematica is useful but not free and Sympy is free but not as useful.

I'm hesitant to build content, given that I can't do anything useful when viewing the graph of everything. Also, queries are not possible; current state is display only.

Wednesday, December 2, 2015

Using EquationMap for content entry

For the Physics Derivation Graph, I started out entering expressions manually into a plaintext file. I then graduated to manually entering expressions into a XML, then CSV file. Rendering was done in GraphViz and then d3js. In the past few months, I created an interactive terminal prompt for a more automated entry using Python, still rendering with d3js. I experimented with a web-based interface using Flask, but recognized I was slowly evolving towards the EquationMap interface for both display and entry.

Instead of re-inventing EquationMap, I realized I could use EquationMap as a front end. I would then export the graph .tex file and parse it into the Physics Derivation Graph. This benefits both EquationMap and the Physics Derivation Graph: EquationMap gets more traffic and more use cases, and PDG doesn't need to create a front-end.

Here's two different examples of using EquationMap with Inference Rules:
http://equationmap.com/#sSCdqOvUii
http://equationmap.com/#6NXnawarhb
I like the second instance better.

Here's an example of completing the square without inference rules
http://equationmap.com/#OZbmPo15Ha
and with inference rules
http://equationmap.com/#7xXumkNaTH
and generalized symbolically
http://equationmap.com/#xq8KZ0bnkT

I like the fact that I can easily refer to different iterations of the development

The ease of entering Latex and connecting nodes is very convenient!

The export function produces a combination of JSON and Latex.
I've written a parser for the .tex output from EquationMap

https://github.com/allofphysicsgraph/proofofconcept/tree/gh-pages/sandbox/equationMap_tex_parser