-
Notifications
You must be signed in to change notification settings - Fork 276
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
figure out what to do about errors from rounding midway through #64
Comments
@evykassirer great project! In this case you could multiply both sides by 1.3, but that's not a very general solution. You probably want to use a bignum library, there are a couple written in JS. I forgot which one I used, but it stored decimals as fractions which should get around this problem. There's still the question of what to display to students. Maybe you could use ellipsis when presenting decimals that continue, or, even better, a bar over the repeating part. In this case 1.9230769230769 the 230769 repeats. |
thanks Kevin! :) oo the bar or ellipses sounds like a nice solution. Although I think the reason we started rounding in the first place was floating point errors - that's what the bignum library is for right? Storing decimals as fractions miiiight not work for all cases - e.g. square roots giving irrational numbers (but I think right now it keeps it as a square root and doesn't calculate it) |
Right.
Excellent! |
Hello! Throwing some thoughts in: ellipsis are an elegant solution if the goal is to obtain an exact result, but sometimes when doing simple arithmetic we only care about an approximate result. As @evykassirer mentioned in those cases it makes sense to round midway. Maybe at that point the system could mark all subsequent nodes as "approximate", so that instead of displaying equality signs to the user we may display "≈" signs. An extra-awesome feature (which would be particularly useful when doing physics-related arithmetic) would be to keep track of the error-margin for each step. Probably outside the scope of this project for now though. |
@hmaurer I agree that sometimes it makes more sense to round and use "≈". It would be nice both approaches were available and configurable. |
@evykassirer would you be interested in a PR for integrating a bignum library? I can make it optional. What would be a good way to specify options? |
Hello! Great discussion 🔢 I like these ideas re "≈": Since there's no "=" between steps (for expressions), just a list of steps, I think the way it would work is that we'd label the nodes (like @hmaurer said) as approximate, and the user of Also, I guess equations would be different because there is an equals sign. So would we want to use re bignum: @kevinbarabash I think that would be a great idea. Interested in @aelnaiem's thoughts (he was my mentor at Socratic and has worked on this project, so he might want to have input on this). So just to confirm, it would work like this?
There aren't really any global options for From a quick Google search it seems like one option is creating a file called |
@evykassirer math.js has bignum functions built into. I'm going to use those so that we don't introduce another dependency. As for options, I think it's probably useful to have both |
Oh perfect, thanks math.js! Sounds good to me. Ahmed ( my mentor from last term @aelnaiem, who was overseeing general math stuff at Socratic ) was on vacation last week, so we haven't figured out how much say he'll have in decisions around stuff like this - so I'd like to check in with him before we merge, but I'm pretty sure it'll be fine so feel free to start working on it if you like :) thanks so much 😸 |
After doing some digging it turns out math.js' bignum is arbitrary precision math and doesn't use fractions. Thankfully, math.js also as a fraction library. I'm going to give that a try instead. |
Something else to consider, with this particular equation |
Yes, good point. I'd do the same as you. Definitely a limitation of algorithm. Pretty much, we implemented equation support pretty naively and simplify both sides completely (the same way we simplify expressions) and then move things around one step at a time. I think the pedagogy for equations has a lot that can be worked on, and will probably complicate the codebase a bit. Will be fun to think about and work on in the near future :) We could maybe open and issue with this example ("improve equation pedagogy" or something) to brainstorm this stuff more |
@evykassirer It could be discussed in #49 |
#49 is related, but I see it more as a special case of equation support I'd still like to have some general discussion where we can think about equation pedagogy and figure out what changes should be made to existing supported equations (like what Kevin was talking about) and new ones we don't support yet (e.g. #49 and #48 ) |
@evykassirer ah, yes. A discussion on the pedagogy of solving equations / simplifying will also touch to #45. I'll wait until an issue is created to talk about it, but as a quick question: should we be concerned about handling non-linear (e.g. quadratic) equations? |
@kevinbarabash do you know if this issue is fixable before the new tree? or should we have it blocked on that |
@evykassirer I think this will be easier to tackle afterwards if we want to use fraction.js. If we're okay with marking values as approximate then we could probably add that to the current system without to much effort. It wouldn't be an extra prop we'd have to copy whenever evaluating values. If any operand is marked as an approximate value than the result of the operation involving that operand would also be marked as an approximate value. |
I'll leave this as blocked for now then, and if the tree is taking a while or there's less work to be done elsewhere, I'll open an issue for that solution in the meantime :) Thanks! |
This is an alternative way to solve this problem:
|
This solution performs division in step 2:
|
Blocked on a new parse tree that Kevin is working on. When we have the new tree, we'll be able to add clearer information about approximate values and won't have to round!
so it's good pedagogically to round partway through, but then we can get the wrong answer in the end!
e.g. this gives us 6.399 when it should actually be 6.4 :(
x - 3.4 = ( x - 2.5)/( 1.3)
steps (approximately, to give an idea of why this happens):
x - 3.4 = x/1.3 - 2.5/1.3
x - 3.4 = x/1.3 - 1.9231
(maybe we wouldn't divide here, but how would we make that call easily?)(1 - 1/1.3) x = 3.4 - 1.9231
0.2308x = 1.4769
x = 6.399
I'm not really sure what the best pedagogical solution is! having really long numbers in the middle wouldn't really be great. What would we want to show the user?
The text was updated successfully, but these errors were encountered: