-
Notifications
You must be signed in to change notification settings - Fork 0
/
amcli.1
120 lines (90 loc) · 3.09 KB
/
amcli.1
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
.TH amcli 1 "amcli"
.SH DESCRIPTION
Why use it?
- Free and cross-platform
- CLI interface for script automations
- Piping for complex operations
- Fast and small
.SH SUBCOMMANDS
.TP
\fBeval\fR
to evaluate into a single number, boolean, or a+bi form at for complex numbers. Expects one argument.
Example:
$ amcli eval "1 / 2"
0.5
$ amcli eval "e ^ pi > pi ^ e"
true
.TP
\fBdiff\fR
to differentiate the expression over the given variable (the first argument). Expects two arguments.
Example:
$ amcli diff "x" "sin(x)"
cos(x)
$ amcli diff "x" "1 + x^2"
2 * x
$ echo "1 + x^2" | amcli diff "x"
2 * x
.TP
\fBsimp\fR
to simplify the expression. Expects one argument.
Example:
$ amcli simp "sin(x)^2 + cos(x)^2"
1
.TP
\fBfsimp\fR
to simplify the expression "faster". This one works closer to eval than to simp, but unlike eval, it won't try to collapse to a single number or boolean (e. g. sqrt(3) will stay as it is). Expects one argument.
Example:
$ amcli fsimp "sin(x)^2 + cos(x)^2"
1
.TP
\fBsolve\fR
to solve a *statement* over the given variable. A *statement* is an expression, otherwise evaluable to true or false (e. g. "x > 3" is a statement, but "x ^ 2" is not).
When the solution set is a finite solution, all solutions are written line-by-line. Otherwise, it's written as one line.
Example:
$ amcli solve "x" "x2 - 1 = 0"
1
-1
$ amcli solve x "x2 > 1"
(-oo; -1) \/ (1; +oo)
.TP
\fBlatex\fR
to convert an expression into LaTeX format. Expects one argument.
Example:
$ amcli latex "1/2"
\frac{1}{2}
$ amcli latex "(sqrt(3) + x) / limit(sin(x) / x, x, 0)"
\\frac{\\sqrt{3}+x}{\\lim_{x\\to 0} \\left[\\frac{\\sin\\left(x\\right)}{x}\\right]}
.TP
\fBsub\fR
to substitute an expression instead of a variable. Expects three arguments (variable to substitute, expression to be substituted instead of the variable, expression).
Example:
$ amcli sub x pi "sin(x / 3)"
sin(pi / 3)
$ amcli sub x "pi / 3" "sin(x)"
sin(pi / 3)
.SH PIPING
.TP
Any argument can be received either as a CLI argument or through standard input.
For example,
amcli eval "1 + 1"
is equivalent to
echo "1 + 1" | amcli eval
This allows to pipe complex evaluations:
echo "sin(x) * cos(y)" \ # 0. initial expression
| amcli diff x \ # 1. differentiate over x
| amcli sub x y \ # 2. substitute y instead of x
| amcli diff y \ # 3. differentiate over y
| amcli sub y "pi/3" \ # 4. substitute pi/3 instead of y
| amcli simplify # 5. simplify
Prints
-1/2 * sqrt(3)
Special symbol "_" (underscore) can be used to use stdinput instead of an argument. For instance, if you want to substitute the result of an operation into another expression:
echo "e^x" \
| amcli sub u _ "u / (1 + u)" \
| amcli sub x 10 \
| amcli eval
Here the result of `echo` is substituted instead of the second argument of `amcli sub`, not the last one.
.SH OTHER
You can bind amcli to @ using aliases. On Unix-like operating systems, add
alias @=amcli
(or specify the full path)