Example: Simple Harmonic Oscillator
The output of the sequence of prompts below is DERIVATION_FILE.tex.
Assuming the initial material is on Wikipedia,
For an example use of the above prompt, see this comment.
Optional (as needed):
Occasionally manual review identifies gaps in explanation. Then additional prompting might be necessary. For example,
Now DERIVATION_FILE.tex should be as complete and as detailed as possible.
There are four actions to take with this .tex file:
DERIVATION_FILE.tex to PDF to ensure validity and no duplicate labels (e.g., Overleaf)DERIVATION_FILE.tex to symbols.jsonDERIVATION_FILE.tex to operations.jsonDERIVATION_FILE.tex to expressions.jsonDERIVATION_FILE.tex to steps.jsonDERIVATION_FILE.tex to symbols.jsonExample: symbols for Simple Harmonic Oscillator
To get scalar symbols in PDG use
curl --silent --insecure https://localhost/api/v1/resources/symbol/scalars | python3 -c "
import sys, json
data = json.load(sys.stdin)
data.pop('_links', None)
if '_embedded' in data and 'scalar_symbols' in data['_embedded']:
for entry in data['_embedded']['scalar_symbols']:
entry.pop('_links', None)
entry.pop('author_name_latex', None)
print(json.dumps(data, indent=2))
"
DERIVATION_FILE.tex to operations.jsonOutput is operations.json
To get operation symbols in PDG use
curl --silent --insecure https://localhost/api/v1/resources/symbol/operations | python3 -c "
import sys, json
data = json.load(sys.stdin)
data.pop('_links', None)
if '_embedded' in data and 'operation_symbols' in data['_embedded']:
for entry in data['_embedded']['operation_symbols']:
entry.pop('_links', None)
entry.pop('author_name_latex', None)
print(json.dumps(data, indent=2))
"
To validate output expressions.json against the schema,
import json
from jsonschema import validate
schema = { ... } # The schema
data = [ ... ] # JSON data
# This will raise a ValidationError if the data is inconsistent
validate(instance=data, schema=schema)
print("JSON is valid!")
To get expressions in PDG use
curl --silent --insecure https://localhost/api/v1/resources/expressions | python3 -c "
import sys, json
data = json.load(sys.stdin)
data.pop('_links', None)
if '_embedded' in data and 'expressions' in data['_embedded']:
for entry in data['_embedded']['expressions']:
entry.pop('_links', None)
entry.pop('author_name_latex', None)
print(json.dumps(data, indent=2))
"
Output is expressions.json
(Manually) input expressions that didn't match using web UI to generate new IDs; then re-run search for matches.
TODO: associate symbol IDs with each expression
TODO: associate operation IDs with each expression
TODO: for each expression rewrite SymPy using PDG IDs
DERIVATION_FILE.tex to steps.jsonExample: steps in Simple Harmonic Oscillator
Output: steps.json
TODO: replace labels with PDG IDs for expressions.