Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RealAbs and RealSign #885

Merged
merged 4 commits into from
Jul 21, 2023
Merged

RealAbs and RealSign #885

merged 4 commits into from
Jul 21, 2023

Conversation

mmatera
Copy link
Contributor

@mmatera mmatera commented Jul 20, 2023

This PR implements two new builtins. Also, its low-level implementation is used to simplify some of the low-level eval functions in arithmetic and testing expressions.

@mmatera mmatera marked this pull request as ready for review July 20, 2023 23:47
<dd>returns $-1$, $0$ or $1$ depending on whether $x$ is negative,
zero or positive.
</dl>
'RealSign' is also known as $sgn$ or $signum$ function.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is signum, we should add that before the WMA link a wikipedia link: https://en.wikipedia.org/wiki/Sign_function

@@ -6,10 +6,12 @@
from mathics.core.expression import Expression
from mathics.core.systemsymbols import SymbolDirectedInfinity


# TODO: Remove me. The following function is not used anywhere
Copy link
Member

@rocky rocky Jul 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is not used, please remove it. It will live pretty much forever in git.

@rocky
Copy link
Member

rocky commented Jul 21, 2023

LGTM - just small comments about documenting RealSign and the placement of the new builtins. Merge whenever you feel ready.

@rocky
Copy link
Member

rocky commented Jul 21, 2023

I see RealSign and RealAbs under Numerical Functions not Testing Expressions

<dt>'RealAbs[$x$]'
<dd>returns the absolute value of a real number $x$.
</dl>
'RealAbs' is also known as modulus. It is evaluated if $x$ can be compared \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment about Wiki reference.

@mmatera
Copy link
Contributor Author

mmatera commented Jul 21, 2023

I see RealSign and RealAbs under Numerical Functions not Testing Expressions

Right now, they are under mathics.builtin.arithmetic

@mmatera
Copy link
Contributor Author

mmatera commented Jul 21, 2023

Regarding the place, and to reduce the noise, I prefer to keep RealAbs and RealSign where Abs and Sign were before this PR. Currently, the mathics.builtin.arithmetic module is orthogonal to what you can find in https://reference.wolfram.com/language/guide/ArithmeticFunctions.html. At the end of the "arithmetic refactor", we can put the pieces in modules according to the WL documentation.

@mmatera mmatera merged commit ada4a4a into master Jul 21, 2023
11 checks passed
@mmatera mmatera deleted the RealAbs_and_RealSign branch July 21, 2023 01:18
<url>:WMA link:https://reference.wolfram.com/language/ref/RealAbs.html</url>

<url>
:Signum:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The link name should be what Wikipedia calls it, so this should be "Sign function". Wikipedia mentions that this is also called "Signum"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I can change this in another iteration.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have included that change in #886, which is the next round of patches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants