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

\cdot y parses incorrectly #33

Open
bengolds opened this issue Feb 16, 2022 · 3 comments
Open

\cdot y parses incorrectly #33

bengolds opened this issue Feb 16, 2022 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@bengolds
Copy link

There are a few different signs that can be used for multiplication: *, \cdot, and \times. They are inconsistent in how they parse when an argument is missing.

x * y       => [ 'Multiply', 'x', 'y' ]       👍
x \cdot y   => [ 'Multiply', 'x', 'y' ]       👍
x \times y  => [ 'Multiply', 'x', 'y' ]       👍

-- Right side missing
x *         => [ 'Multiply', 'x', 'Missing' ] 👍
x \cdot     => [ 'Multiply', 'x', 'Missing' ] 👍
x \times    => [ 'Multiply', 'x', 'Missing' ] 👍

-- Left side missing
  * y       => [ 'Multiply', 'Missing', 'y' ] 👍
  \cdot y   => [ 'Multiply', '\\cdot', 'y' ]  ❌ 
  \times y  => [ 'Multiply', '\\times', 'y' ] ❌ 

@arnog arnog self-assigned this Feb 16, 2022
@arnog arnog added the bug Something isn't working label Feb 16, 2022
@strickinato
Copy link

Tested this out in 0.4.3 - and there are still some inconsistencies:

  'x * y'        --> [ 'Multiply', 'x', 'y' ]
  'x \\cdot y'   --> [ 'Multiply', 'x', 'y' ] 
  'x \\times y'  --> [ 'Multiply', 'x', 'y' ]
  'x *'          --> [ 'Error', 'x', "'syntax-error'", [Array] ]
  'x \\cdot'     --> [ 'Error', 'x', "'syntax-error'", [Array] ] 
  'x \\times'    --> [ 'Multiply', 'x', 'Missing' ]
  '* y'          --> [ 'Error', 'Nothing', "'syntax-error'", [Array] ]
  '\\cdot y'     --> [ 'Error', [Array], "'syntax-error'", [Array] ]
  '\\times y'    --> [ 'Error', [Array], "'syntax-error'", [Array] ] ]

@DataDaoDe
Copy link

DataDaoDe commented Aug 25, 2022

Maybe this is the wrong context, but each of these can mean different conceptualizations (and computations) of multiplication depending on the types of x and y. For instance, when dealing with matrices \times denotes the cross product of two vectors and \cdot the dot product. Wouldn't this need to be taken into account?

@arnog
Copy link
Member

arnog commented Oct 3, 2022

With 0.8.0 the output is:

x * y         => x \cdot y
x \cdot y     => x \cdot y
x \times y    => ["Multiply", "x", "y"]
x *           => ["Sequence", "x", ["Error", [ "ErrorCode", "'unexpected-token'",... ["Latex", "'*'"]]]
x \cdot       => ["Sequence", "x", ["Error", [ "ErrorCode", "'unexpected-command'",... ["Latex", "'\\cdot'"]]]
x \times      => ["Multiply", "x", ["Error", "'missing'"]]
* y           => ["Multiply", ["Error", "'missing'", ["Latex", "'*'"]], "y"
\cdot y       => ["Multiply", ["Error", "'missing'", ["Latex", "'\\cdot'"]], "y"
\times y      => ["Multiply", ["Error", "'missing'", ["Latex", "'\\ times'"]], "y"]

@DataDaoDe yes, but the default setup of the Compute Engine is to assume that unknown symbols are Real numbers. The domain of the symbols can be taken into account during parsing to determine if this is a scalar multiplication or a cross product.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

4 participants