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

Exponentiation seems broken? #221

Closed
vrmiguel opened this issue Jul 14, 2023 · 2 comments
Closed

Exponentiation seems broken? #221

vrmiguel opened this issue Jul 14, 2023 · 2 comments

Comments

@vrmiguel
Copy link

vrmiguel commented Jul 14, 2023

Hey @printfn, really cool project!

I've been looking for a Rustier version of sharkdp's insect for a while, so I'm glad this showed up :D

Steps to reproduce error

I'm trying to reproduce the good old trig identity of sin²(x) + cos²(x) == 1 but something seems off:

> x = 2
2
> sin(x)**2 + cos(x)**2
approx. -1.4104461161
> sin(x)^2 + cos(x)^2
approx. -1.4104461161
> sin(x)*sin(x) + cos(x)*cos(x)
approx 1

Happens on latest main and also on the WASM build on GitHub Pages

@printfn
Copy link
Owner

printfn commented Jul 14, 2023

Thanks for the report! This bug is caused by incorrect operator precedence handling. For example, (sin x)**2 + (cos x)**2 does produce the correct result of 1. It's related to issue #76.

@vrmiguel
Copy link
Author

Oooh, got it

In this case I'll close this one as a duplicate of #76

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

2 participants