Skip to content

AngouriMath has no rounding functions (floor, ceil, round), nor min, max or gcd #809

Description

@Rafael-SOWNet

Split out of #733 at @Happypig375's request — "the inclusion of those functions belong to their own issue".

#733 was about these names being silently read as products (floor(x)floor * x). That is fixed: every one of them is now refused by name, with a message saying what is missing. What is left is the functions themselves, which is a feature rather than a defect.

Measured on master (21f0d16)

floor(x) UnrecognizedFunctionParseException
ceil(x) UnrecognizedFunctionParseException
round(x) UnrecognizedFunctionParseException
min(3, 5) UnrecognizedFunctionParseException
max(3, 5) UnrecognizedFunctionParseException
gcd(12, 18) UnrecognizedFunctionParseException

For contrast, the neighbours that do exist:

sign(x) sgn(x)
abs(x) abs(x)

Why they are not just three more grammar lines

log10 and factorial were added to the grammar because a node already existed behind them. These have no node, so each needs a decision before a rule:

  • floor / ceil / round — need a node, a derivative (zero almost everywhere, undefined on the integers), a Latexise form, and a rule for what they mean on a complex argument. round additionally needs a tie-breaking convention (half away from zero, or half to even).
  • min / max — expressible as (a + b - abs(a - b))/2 and (a + b + abs(a - b))/2, so they could be sugar over abs rather than nodes. That is a design choice: sugar simplifies well and prints badly, a node prints well and needs its own rules everywhere.
  • gcd — only defined on integers, so it needs a decision about what it does with a symbolic or non-integer argument. Providedf is the obvious answer but is worth agreeing before implementing.

Adding any of these introduces a new Entity subtype, which is a breaking change for consumers that switch exhaustively over the node hierarchy — see #248 for that discussion.

Sensible to take them separately rather than as one change; min/max are the cheapest and round the most opinionated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ProposalContribute to the project by proposing some improvements

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions