I spotted in the documentation that a new command, formatLatex, now exists - and seems to aim to solve a problem we’ve all had with tidying up latex expressions potentially involving adding negatives etc.
The documentation says it “applies a small set of simplification rules to format the equations and expressions nicely”. I’ve had a quick play around and it seems to sort out most, but not all, of the “obvious” tidy-ups:
I like that it simplifies the 1x^2 expression and neatly sorts out the ± issue for the constant. I’m not sure whether the ±5x not being sorted is by design or just a bug, but it would be nice if eventually that also was tidied up.
Has anyone else found any other bits of expressions that tidy up nicely through formatLatex?
I’ll work on getting together a list of the simplification rules we applied. For your case, though, its definitely a bug. A few cases like this have popped up here and there, but any new examples are more than welcome.
I’d like to propose an alternative for this thread: are there any expressions that you expected to be tidied up but were not? Raw expressions, expected format, and actual format would be super helpful!
This is great. I’ll have to think about it. One wonder I have is whether there can be parameters that would allow you to push things in one way or another. For example, change all subtractions to adding the opposite would also be a nice feature (instead of the other way around). This would help with the pattern matching because you could then use sums only.
Oh, great - that’s a lot simpler than the previous solution for pattern matching a polynomial.
But it’s funny, I don’t think of changing subtraction to adding the opposite as making it more complicated. In fact, I teach this strategy to my 9th graders because it helps them see the structure of an expression more clearly. For example, if they have 3x - 2(x + 5), they are likely to change it to 3x - 2x + 10. But if they first write 3x + -2(x + 5) then they no longer make that mistake.
Or if they solve 10 - 2x = 4, they often subtract 10 and write 2x = -6, with the negative sign vanishing. But rewriting first as 10 + -2x = 4 helps them focus on the actual structure and cuts down on mistakes and confusion.
I mean complicated in terms of formatting. Whereas the current formatting attempts to “remove the extra things”, the opposite would do what? And where? And what would be the limits? “Add in the extras but only certain ones” feels thorny, I’d love to hear a list of rules you envision would propose for this (truly, honestly interested).
Is there anywhere for us to keep an eye on new additions to the pattern matching aspects while they’re being developed, or is it just a case of occasionally scouring the autocompletion options and seeing what surprises there are?
Well, right now, I can’t actually think of other cases that would be useful, and allowNegativeTerms takes care of the one I described.
But to try and answer the question, if formatLatex is using the heuristic of “get rid of extra stuff”, then maybe what I am thinking about is more like a specific function that could be called on a latex string rather than a parameter of formatLatex. I’m imagining a function that would take latex and return latex following the simple rule that all subtractions are changed to adding a negative.
Oooh what you’re looking for might actually be an expansion of substituteLatexVariable. to accept any part of a latex string instead of strictly variables.
Haven’t done a great job of that, sorry. Do you that think pinning an ongoing list of new features at the top of the announcements section would be useful?
Not entirely, as we also used it for other (larger) announcements. Individual posts for small changes turned out not to be the most efficient. The new idea is a single pinned post that I edit and add to when something new comes up. Less digging, less pings, etc.
I’d certainly like that idea, as I enjoy playing around with new stuff as and when it’s released and considering how it might improve future activities I build. I guess it would not be of interest to everyone, but a single post with updates is a nice, avoidable option.
Usually the commands are self-explanatory enough / discoverable enough that I don’t think we’d even need massive examples to support - I quickly figured out the applications and limitations of substituteLatexVariable, for example, when that first appeared. (Though I’ll admit evaluationFrame had me beat until I saw the full documentation!)
Certainly pattern matching improvements/additions would be good to see as they arrive, as they’re less discoverable - though I guess you are also developing the documentation for that too, so I wouldn’t want to distract from that.
Will there be something in the announcements tab at some stage about the new relationship with amplify and the implications for activity builder and computation layer?
There’s nothing planned for this space, but everything you need to know can be summed up in this paragraph from our public release:
If you love Activity Builder and other free tools at teacher.desmos.com, we have good news. They will continue to be free, continue to power our curriculum, and continuously improve.
Love this–this makes things so much simpler!
{Update: I checked this out and it looks like what I’m wanting below already exists.}
One thing I’d like to see is like the 1x term changing to x, it’d be great to have the 0x term not display. I’m thinking of the case where I build a polynomial with random variables and want to have the range to allow negatives and positives but skip the 0 term when that comes up if that makes sense. Maybe it already does this?