File: run20.pl

package info (click to toggle)
libmath-symbolic-perl 0.613-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,268 kB
  • sloc: perl: 12,638; makefile: 9
file content (53 lines) | stat: -rwxr-xr-x 1,103 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/perl
use strict;
use warnings;

use lib '../lib';
use Math::Symbolic qw/:all/;

BEGIN {
	warn "foo";
	my $in = <STDIN>;
};

my $latex_str = "\\documentclass[12pt]{article}\n\\begin{document}\n";

# oscillation
my $term = parse_from_string(<<'HERE');
Omega * e^(i*omega*t)
HERE
$latex_str .= $term->to_latex( replace_default_greek => 1 ) . "\n\n";

# Lagrange function of Euler angles
$term = parse_from_string(<<'HERE');
(1/2)*omega*Theta*omega-U(phi, theta, psi, t)
HERE
$latex_str .= $term->to_latex( replace_default_greek => 1 ) . "\n\n";

# mapping Math::Symbolic::Variable names to plain LaTeX
my $vars = {
    p_i => 'p_{i}',
    q_i => 'q_{i}',
};

# i-th term of the Poisson parenthesis
$term = parse_from_string(<<'HERE');
partial_derivative(g, p_i)
*
partial_derivative(f, q_i)
-
partial_derivative(g, q_i)
*
partial_derivative(f, p_i)
HERE
$latex_str .= $term->to_latex(
    replace_default_greek   => 1,
    implicit_multiplication => 1,
    variable_mappings       => $vars
  )
  . "\n\n";

$latex_str .= "\\end{document}\n";

# This is a valid LaTeX document:
print $latex_str;