# formatLatex now exists... could be a game-changer

**URL:** <https://cl.desmos.com/t/formatlatex-now-exists-could-be-a-game-changer/4305>\
**Category:** Discussion\
**Tags:** patterns\
**Created:** [May 18, 2022, 8:40pm UTC](https://cl.desmos.com/t/formatlatex-now-exists-could-be-a-game-changer/4305 "2022-05-18T20:40:05Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![pirsquared](https://avatars.discourse-cdn.com/v4/letter/p/4af34b/32.png) [@pirsquared](https://cl.desmos.com/u/pirsquared)\
**Post date:** [May 18, 2022, 8:40pm UTC](https://cl.desmos.com/t/formatlatex-now-exists-could-be-a-game-changer/4305/1 "2022-05-18T20:40:05Z")

</div>

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](https://teacher.desmos.com/computation-layer/documentation#function:formatLatex) 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:

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/desmos/original/2X/5/5000f220142aaf2a7a95bee8de4f0f2ff563766d.png)

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`?

---

<div class="post-metadata">

**Author:** ![JayChow](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/jaychow/32/1674_2.png) [@JayChow](https://cl.desmos.com/u/JayChow)\
**Post date:** [May 18, 2022, 11:11pm UTC](https://cl.desmos.com/t/formatlatex-now-exists-could-be-a-game-changer/4305/2 "2022-05-18T23:11:31Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Daniel\_Wekselgreene](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_wekselgreene/32/1819_2.png) [@Daniel\_Wekselgreene](https://cl.desmos.com/u/Daniel_Wekselgreene)\
**Post date:** [May 20, 2022, 1:44am UTC](https://cl.desmos.com/t/formatlatex-now-exists-could-be-a-game-changer/4305/3 "2022-05-20T01:44:25Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![JayChow](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/jaychow/32/1674_2.png) [@JayChow](https://cl.desmos.com/u/JayChow)\
**Post date:** [May 20, 2022, 3:38pm UTC](https://cl.desmos.com/t/formatlatex-now-exists-could-be-a-game-changer/4305/4 "2022-05-20T15:38:51Z")

</div>

“make it more complicated”, now thats one I definitely haven’t heard before! Good thing its no longer necessary: [allowNegativeTerms • Activity Builder by Desmos](https://teacher.desmos.com/activitybuilder/custom/6287b4bbf282e3051b46ef2a)

---

<div class="post-metadata">

**Author:** ![Daniel\_Wekselgreene](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_wekselgreene/32/1819_2.png) [@Daniel\_Wekselgreene](https://cl.desmos.com/u/Daniel_Wekselgreene)\
**Post date:** [May 20, 2022, 4:12pm UTC](https://cl.desmos.com/t/formatlatex-now-exists-could-be-a-game-changer/4305/5 "2022-05-20T16:12:29Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![JayChow](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/jaychow/32/1674_2.png) [@JayChow](https://cl.desmos.com/u/JayChow)\
**Post date:** [May 20, 2022, 5:25pm UTC](https://cl.desmos.com/t/formatlatex-now-exists-could-be-a-game-changer/4305/6 "2022-05-20T17:25:00Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![pirsquared](https://avatars.discourse-cdn.com/v4/letter/p/4af34b/32.png) [@pirsquared](https://cl.desmos.com/u/pirsquared)\
**Post date:** [May 20, 2022, 6:10pm UTC](https://cl.desmos.com/t/formatlatex-now-exists-could-be-a-game-changer/4305/7 "2022-05-20T18:10:50Z")

</div>

Another potential game-changer! Thank you!

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?

---

<div class="post-metadata">

**Author:** ![Daniel\_Wekselgreene](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_wekselgreene/32/1819_2.png) [@Daniel\_Wekselgreene](https://cl.desmos.com/u/Daniel_Wekselgreene)\
**Post date:** [May 20, 2022, 7:31pm UTC](https://cl.desmos.com/t/formatlatex-now-exists-could-be-a-game-changer/4305/8 "2022-05-20T19:31:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![JayChow](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/jaychow/32/1674_2.png) [@JayChow](https://cl.desmos.com/u/JayChow)\
**Post date:** [May 20, 2022, 7:49pm UTC](https://cl.desmos.com/t/formatlatex-now-exists-could-be-a-game-changer/4305/9 "2022-05-20T19:49:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![JayChow](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/jaychow/32/1674_2.png) [@JayChow](https://cl.desmos.com/u/JayChow)\
**Post date:** [May 20, 2022, 7:51pm UTC](https://cl.desmos.com/t/formatlatex-now-exists-could-be-a-game-changer/4305/10 "2022-05-20T19:51:41Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Bryn](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/bryn/32/40_2.png) [@Bryn](https://cl.desmos.com/u/Bryn)\
**Post date:** [May 21, 2022, 12:09pm UTC](https://cl.desmos.com/t/formatlatex-now-exists-could-be-a-game-changer/4305/11 "2022-05-21T12:09:19Z")

</div>

Yes! I thought that was the original idea of the “announcements” part of this forum too.

---

<div class="post-metadata">

**Author:** ![JayChow](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/jaychow/32/1674_2.png) [@JayChow](https://cl.desmos.com/u/JayChow)\
**Post date:** [May 21, 2022, 4:13pm UTC](https://cl.desmos.com/t/formatlatex-now-exists-could-be-a-game-changer/4305/12 "2022-05-21T16:13:12Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pirsquared](https://avatars.discourse-cdn.com/v4/letter/p/4af34b/32.png) [@pirsquared](https://cl.desmos.com/u/pirsquared)\
**Post date:** [May 21, 2022, 6:51pm UTC](https://cl.desmos.com/t/formatlatex-now-exists-could-be-a-game-changer/4305/13 "2022-05-21T18:51:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Bryn](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/bryn/32/40_2.png) [@Bryn](https://cl.desmos.com/u/Bryn)\
**Post date:** [May 21, 2022, 8:54pm UTC](https://cl.desmos.com/t/formatlatex-now-exists-could-be-a-game-changer/4305/14 "2022-05-21T20:54:21Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![JayChow](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/jaychow/32/1674_2.png) [@JayChow](https://cl.desmos.com/u/JayChow)\
**Post date:** [May 22, 2022, 4:55am UTC](https://cl.desmos.com/t/formatlatex-now-exists-could-be-a-game-changer/4305/15 "2022-05-22T04:55:53Z")

</div>

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](http://teacher.desmos.com), we have good news. They will continue to be free, continue to power our curriculum, and continuously improve.

The full statement can be found [here](https://blog.desmos.com/articles/desmos-amplify-join-forces/)

In short, you can expect the same tools and the same support to continue and remain free. This forum will also remain open to all.

---

<div class="post-metadata">

**Author:** ![Andy\_Schwen](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/andy_schwen/32/218_2.png) [@Andy\_Schwen](https://cl.desmos.com/u/Andy_Schwen)\
**Post date:** [June 3, 2022, 11:59am UTC](https://cl.desmos.com/t/formatlatex-now-exists-could-be-a-game-changer/4305/16 "2022-06-03T11:59:21Z")

</div>

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?
