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

Multiple division rendering #53

Closed
yueyericardo opened this issue Oct 15, 2020 · 7 comments
Closed

Multiple division rendering #53

yueyericardo opened this issue Oct 15, 2020 · 7 comments

Comments

@yueyericardo
Copy link

handcalcs version: 1.1.3
As shown below, a should be rendered as c, otherwise it's the same rendering with b, which is totally different.

%%render
a = 4/2/2  # The answer will be 4 for the rendered equation
b = 4/(2/2)
c = (4/2)/2  # Should be correct rending
d = 4/(2*2)  # Or this will be better

image

@yueyericardo yueyericardo changed the title Multiple Division Rendering Multiple division rendering Oct 15, 2020
@connorferster
Copy link
Owner

connorferster commented Oct 16, 2020

Hi @yueyericardo, I have been thinking about this one. I intentionally programmed it to render this way but, you are right, it creates a "gotcha" with the a) case because the reduced size of the fraction in the denominator implies that the denominator should be evaluated first, followed by the division of the numerator. At the very least, I should highlight this in the documentation.

What if there was a behaviour that recognized whether or not a portion of a nested fraction was contained within parentheses and only made that portion smaller if it is contained in parentheses (so, the b) and c) case would remain as shown above)?

This would then change the a) case to render as follows:
image

Does that make it less ambiguous? I would still be inclined to interpret that as (4*2) / 2. Personally, while I would punch something like 4 / 2 / 2 into a calculator, when I am working in handcalcs I would be inclined to make it less ambiguous by showing it as the c) or d) case, like you have shown.

Let me know your thoughts on this.

@connorferster
Copy link
Owner

connorferster commented Oct 17, 2020

I guess this is an example of this:
PEDMAS vs Algebra

I think I will just make a note of this in the documentation and leave it at that. Writing 4/2/2 is ambiguous when represented as a nested fraction so I think it would be best just not to write it as a fraction e.g. use 4/(2*2) instead

@michaellisitsa
Copy link
Contributor

Could you check for 2 divisions in a row where there are no brackets, and place the term after the second division separately?
image

@connorferster
Copy link
Owner

connorferster commented Oct 20, 2020

@michaellisitsa,

That's not a bad idea. I don't particularly like it because I have been emotionally attached to my "all division as fractions" approach. It's taken me several hours to just get used to the idea of breaking it (and I am still grieving its loss). However, I think this might be the most attractive and least ambiguous solution even though I shudder imagining an equation written this way and groan a little inside imagining the implementation and testing.

Unless anyone has any other ideas, I will go with this in the next update.

@connorferster
Copy link
Owner

connorferster commented Oct 24, 2020

Okay, I am done being a big baby. Thank you @michaellisitsa for getting me in the creative mode!

I have an idea that I am pretty excited about. Instead of switching from fractions to the slash, I have kept the fractions by doing it this way:

image

It looks like it's fussy to do but it was actually pretty straight forward.

@yueyericardo
Copy link
Author

Cool, I think it's a good idea!

@connorferster
Copy link
Owner

connorferster commented Oct 24, 2020

Glad to hear it! The change has been made and added to the master branch. It will be available in the next release.

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