Asciimath-related mathjs expression extension proposals #3364
gwhitney
started this conversation in
Design decisions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
By now there is a fairly well established Asciimath convention for representing mathematical typography (not exactly mathematical calculation) that would suggest some further additions/features to the mathjs expression language, not to mention quite a few issues/discussions over the years for such feature. So I am creating this discussion to collect such proposals that rely only on the 7-bit ASCII character set (I will create another discussion for Unicode extensions to the mathjs expression language). This can be used to survey the possibilities and hopefully at some point select those worthy of implementation and decide against others.
P => Q <=> R
P implies Q if_and_only_if R
<=>
on boolean values would be identical to==
. Also if we want a simplified notation for anonymous functions (e.g., to use inmap
) one attractive option would bex => x+1
ala JavaScript; on the other hand, the more AsciiMath consistent notation for that would bex |-> x+1
. Otherwise a perfectly sensible proposal.$
r /_ theta
r*(cos(theta) + i*sin(theta))
x && y || z
x and y or z
|x|
abs(x)
a|b
being bitwise or, and even without, is|a|b|c|
parsed asabs(a)*b*abs(c)
orabs(a * abs(b) *c)
-- those are semantically quite different? I see two options for making this parseable: (A) Only interpret|
with whitespace or string boundary immediately adjacent on exactly one side as an absolute value bar; if the whitespace or string start is on the left, then it is an "open absolute" and if whitespace or string end is on the right, it is a "close absolute". Thus the ambiguous expression above would be disambiguated as either|a| b |c|
or|a |b| c|
. All other|
(with whitespace on both sides or neither) would be bitwise OR. (B) Use|.
for open absolute and.|
for close absolute, so that we would write|.x.|
forabs(x)
. (Or possibly|:x:|
if that looked better to people.) With|
so common in mathematical notation, I would recommend serious consideration of one of these proposals or some other parseable scheme along these lines.sum_(i=1)^5 i^2
sum(range(1,5).map(_(i)=i^2)
prod_(i=1)^5 i^2
product(range(1,5).map(_(i)=i^2)
x ?? y
|_ x _|
floor(x)
|~x~|
ceil(x)
|-x-|
round(x)
x -= y (mod m)
(x - y) % m == 0
x |-> x+1
_(x) = x+1
f'(x)
derivative(f, x)
'
is also allowed for string quotes...a uu b nn c
setUnion(a, setIntersect(b))
a /_\ b
setSymDifference(a, b)
v o. w
dotMultiply(v,w)
v xx w
cross(v, w)
A ox B
kron(A,B)
Please feel free to propose additional possibilities for this table or discuss any of the particular proposals above. Thanks!
Beta Was this translation helpful? Give feedback.
All reactions