Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Sources/Terminal/AngouriMath.Terminal.Lib/OneShot.fs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ let usage =
amcli eval EXPR evaluates to a number, a boolean, or a + bi
amcli simp EXPR simplifies
amcli fsimp EXPR simplifies quickly: the normalisation, without the search
amcli diff VAR EXPR differentiates over VAR
amcli solve VAR STATEMENT solves over VAR, one root per line when there are finitely many
amcli diff VAR EXPR differentiates with respect to VAR
amcli solve VAR STATEMENT solves for VAR, one root per line when there are finitely many
amcli sub VAR VALUE EXPR substitutes VALUE for VAR
amcli latex EXPR writes EXPR as LaTeX
amcli info EXPR its variables, derivatives, roots and stationary points
Expand Down Expand Up @@ -84,17 +84,17 @@ let private kindOfStationaryPoint (hessian: int -> int -> Entity) (size: int) =
else "a saddle point"

/// <summary>
/// The lines <c>amcli info</c> prints: the variables, the derivative and the roots over each, and
/// The lines <c>amcli info</c> prints: the variables, the derivative and the roots for each, and
/// the stationary points, each classified by the second derivative test.
/// </summary>
let private describe (expression: Entity) =
let variables = expression.Vars |> Seq.toList
let names = String.Join(", ", variables)
[ yield $"variables: {names}"
for v in variables do
yield $"derivative over {v}: {expression.Differentiate(v).Simplify().Stringize()}"
yield $"derivative with respect to {v}: {expression.Differentiate(v).Simplify().Stringize()}"
for v in variables do
yield $"roots over {v}: {expression.Equalizes(Entity.Number.Integer.Zero).Solve(v).Simplify().Stringize()}"
yield $"roots for {v}: {expression.Equalizes(Entity.Number.Integer.Zero).Solve(v).Simplify().Stringize()}"
match variables with
| [] -> ()
| [ v ] ->
Expand Down
6 changes: 3 additions & 3 deletions Sources/Terminal/AngouriMath.Terminal/amcli.1
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ quickly: the normalisation, without the search.
.BI diff " var expr"
Differentiates
.I expr
over
with respect to
.IR var .
.TP
.BI solve " var statement"
Solves
.I statement
over
for
.IR var ,
one root per line when there are finitely many.
.TP
Expand All @@ -63,7 +63,7 @@ as LaTeX.
.BI info " expr"
Describes
.IR expr :
its variables, the derivative and the roots over each, and its stationary points, each classified
its variables, the derivative and the roots for each, and its stationary points, each classified
by the second derivative test.
.TP
.B help
Expand Down
2 changes: 1 addition & 1 deletion Sources/Terminal/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ $ echo "1 + x^2" | amcli diff x

The commands are `eval`, `simp`, `fsimp`, `diff`, `solve`, `sub`, `latex` and `info`, and
`amcli help` says what each takes. `info` describes an expression: its variables, the derivative
and the roots over each, and its stationary points, each classified by the second derivative
and the roots for each, and its stationary points, each classified by the second derivative
test. An argument written as `_`, or left out, is read from stdin. The exit code
is 0 for an answer, 1 when the input does not parse or cannot be answered, and 2 for a command
that does not exist or is missing an argument. These are the commands of the earlier standalone
Expand Down
6 changes: 3 additions & 3 deletions Sources/Tests/TerminalUnitTests/OneShotTest.fs
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ let ``info classifies each stationary point`` (expression: string) (expected: st
Assert.Contains(expected, printed.Split('\n'))

[<Fact>]
let ``info names the variables and gives the derivative and the roots over each`` () =
let ``info names the variables and gives the derivative and the roots for each`` () =
let code, printed, _ = run [ "info"; "x^2 - 4" ] ""
Assert.Equal(0, code)
let lines = printed.Split('\n')
Assert.Contains("variables: x", lines)
Assert.Contains("derivative over x: 2 * x", lines)
Assert.Contains(lines, fun line -> line.StartsWith("roots over x: ") && line.Contains("-2") && line.Contains("2"))
Assert.Contains("derivative with respect to x: 2 * x", lines)
Assert.Contains(lines, fun line -> line.StartsWith("roots for x: ") && line.Contains("-2") && line.Contains("2"))
Loading