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

Inconsistent sqrt syntax #139

Open
timokoesters opened this issue Mar 30, 2024 · 4 comments
Open

Inconsistent sqrt syntax #139

timokoesters opened this issue Mar 30, 2024 · 4 comments

Comments

@timokoesters
Copy link
Contributor

√(2)×2 is 2√2, but
√2×2 = √4 = 2

I think multiplication should always be parsed as being outside of the sqrt.

@PaddiM8
Copy link
Owner

PaddiM8 commented Mar 30, 2024

Hmm this is a tricky one, because you would expect something like cos2x to be parsed as cos(2x) but sqrt2*2 as sqrt(2) * 2 I guess. Maybe it should make a distinction between implicit and explicit multiplication in this context? That's what Wolframalpha seems to do.

Your issues have been really helpful by the way. Thanks!

@timokoesters
Copy link
Contributor Author

Even better, WolframAlpha differentiates between cos 2 x and cos 2x. I think leaving a space is the same as explicit multiplication

@PaddiM8
Copy link
Owner

PaddiM8 commented Mar 30, 2024

Oh yeah that makes sense. A bit trickier to parse, but should be possible

@Kuuuube
Copy link

Kuuuube commented Jul 20, 2024

I think a bigger issue here is this:

√2*2 = √(2*2) = 2

but then also this:

√2+2 = √(2)+2 = 3.41...

The sqrt should either be greedy and capture any operation after it or capture nothing after it (unless theres parentheses wrapping everything under the sqrt) not both at the same time depending on the operator.

For example this is how I think they should be parsed:

√2*2 = √(2)*2 = 2.82...
√2+2 = √(2)+2 = 3.41...

and require the user to add parentheses for these operations to be pulled into the sqrt:

√(2*2) = 2
√(2+2) = 2

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

No branches or pull requests

3 participants