I find communicating how optimization works difficult.
As for space optimization, its sort of like, you imagine picking up multiple pieces at once and sliding them around as a single object, sometimes rotating the block, or flipping it. Sometimes you grab the segments branching off of a single piece and slide them along the edges of the central piece and swap the branches' places. Another tool is if can imagine cutting the whole spell along a horizontal or vertical line and bridging the gaps using connector pieces to loosen the structure and give yourself more space to rearrange more
Other than the literal rearrangement of pieces, you often think about the broad functionality of a block. What's the space of possible inputs this block is going to be given? This other block gives the wrong output for negative values, but it only ever receives values 0-1, so it works. Does it need to be exact, or will a bit of error still work? It might be easier to read if you do it one way, but you can do the same thing in less steps if you take this obscure route.
Anyways, heres an optimization of your thing I did: https://imgur.com/a/avcwQtr