Physics Derivation Graph navigation Sign in

Recommendation: Read the user documentation and FAQ first. This page assumes familiarity with the jargon used in the Physics Derivation Graph.

This page compares Computer Algebra Systems (CAS) for use with the Physics Derivation Graph (PDG).

Comparison of Computer Algebra Systems

Sage, Mathematica, and SymPy are candidates capable of checking the correctness of derivations.

Sage

The following Sage code checks that the claimed step as stated by the inference rule is carried out correctly:

T=var('T')
f=var('f')
# latex input: T = 1/f
input_expr = (1)/(f) == (T)
# latex output: T f = 1
expected_output_expr = T * f == 1
# latex feed: f
feed = f
input_expr * feed == expected_output_expr
The output is
True
which means that the claimed step in the derivation was implemented consistent with the inference rule applied.

Sage code can be run in https://sagecell.sagemath.org/.

In this analysis of Sage the support for standard operations wasn't sufficient.

Mathematica

A computer algebra system like Mathematica can validate the steps of a derivation.

Input:

multiplyBothSidesOfExpression[LHS_, relation_, RHS_, feed_] := {LHSout = LHS*feed, relationOut = relation, RHSout = RHS*feed}
divideBothSidesOfExpression[LHS_, relation_, RHS_, feed_] := {LHSout = LHS/feed, relationOut = relation, RHSout = RHS/feed}

LHS = T;
RHS = 1/f;
relation = "=";
{LHS, relation, RHS}

result = multiplyBothSidesOfExpression[LHS, relation, RHS, f]; (* should yield T*f=1 *)
result = divideBothSidesOfExpression[result[[1]], result[[2]], result[[3]], T]; (* should yield f=1/T *)

{result[[1]], result[[2]], result[[3]]}

Output:

{T,=,1/f}

{f,=,1/T}
Quadratic equation derivation
First, set up the inference rules:
dividebothsidesby[expr_, x_] := Apart[First[expr]/x] == Apart[Last[expr]/x];
subtractXfromBothSides [expr_, x_] := First[expr]-x == Last[expr]-x;
addXtoBothSides[expr_, x_] := First[expr]+x == Last[expr]+x;
subXforY[expr_, x_, y_] := expr /. x -> y
raiseBothSidesToPower[expr_, pwr_] = First[expr]^pwr == Last[expr]^pwr
simplifyLHS [expr_, condition_] := FullSimplify [First[expr], condition] == Last[expr]
Next, use the inference rules
func = a*x^2+b*x+c == 0
func = dividebothsidesby[func, a]
func = subtractXfromBothSides [func, c/a]
func = addXtoBothSides[func, (b/(2 a))^2]
func = subXforY[func, First[func], (x+b/(2 a))^2]
func = subXforY[func, Last[func], (b^2-4 ac)/(4 a^2)]
func = raiseBothSidesToPower[func, (1/2)]
func = simplifyLHS [func, (x+b/(2 a)) > 0]
func = subXforY[func, Last[func], ±Last[func]]
func = subtractXfromBothSides [func, b/(2 a)]

Sympy

The motives for using Sympy are the cost (free), the code (open source), the integration (Python), support for Physics, and the support for parsing Latex.

The snippets of SymPy can be run in http://live.sympy.org/