### Related

##### collapse-ratsimp-xthru

a: 1/(c-d)-c/(c^2-d^2...

xthru(a);

b:ratsimp(a);

Calculate

##### collapse-expand

eq1:zz : a + b*xx + c...

eq2: expand(eq1);

collapse(eq2);

Calculate

##### collapse-optimize-ratsimp-xthru

a: 1/(c-d)-c/(c^2-d^2...

xthru(a);

b:ratsimp(a);

Calculate

##### collapse-expand-sqrt

a:-sqrt(-1)/o/P*(-sqr...

b:expand(a);

c:collapse(b);

Calculate

##### collapse-linsolve-lsum

eq1 : I + ri*t*B = mi;

eq2 : O + ro*(1-t)*B ...

eq3 : B = t*I + (1-t)*O;

Calculate

##### collapse-expand-sqrt

a:-sqrt(-1)/o/P*(-sqr...

b:expand(a);

c:collapse(b);

Calculate

##### collapse-constant-declare-optimize-ratsimp-xthru

declare(c,constant);

declare(d,constant);

declare(x,constant);

Calculate

? collapse;

Calculate

##### collapse-expand-sqrt

a:-sqrt(-1)/o/P*(-sqr...

b:expand(a);

c:collapse(b);

Calculate

##### collapse-optimize-ratsimp-xthru

a: 1/(c-d)-c/(c^2-d^2...

xthru(a);

b:ratsimp(a);

Calculate

### collapse

Run Example
```(%i1)a: 1/(c-d)-c/(c^2-d^2)+1/(2*c+2*d);
c          1         1
(%o1)                    - ------- + --------- + -----
2    2   2 d + 2 c   c - d
c  - d
(%i2) xthru(a);
2    2
(d + 3 c) (c  - d ) - c (c - d) (2 d + 2 c)
(%o2)             -------------------------------------------
2    2
(c - d) (2 d + 2 c) (c  - d )
(%i3) b:ratsimp(a);
1
(%o3)                             - ---------
2 d - 2 c
(%i4) p: x/(x^2-y^2)-y/(x^2+2*x*y+y^2);
x             y
(%o4)                      ------- - ---------------
2    2    2            2
x  - y    y  + 2 x y + x
(%i5) q:ratsimp(p);
2    2
y  + x
(%o5)                       - ---------------------
3      2    2      3
y  + x y  - x  y - x
(%i6) collapse(2*c+2*d);
(%o6)                              2 d + 2 c
(%i7) optimize(2*c+2*d);
(%o7)                              2 d + 2 c
(%i8) ```
Run Example
```? collapse;

-- Function: collapse (<expr>)
Collapses <expr> by causing all of its common (i.e., equal)
subexpressions to share (i.e., use the same cells), thereby saving
space.  (`collapse' is a subroutine used by the `optimize'
a `save' file.  You can collapse several expressions together by
using `collapse ([<expr_1>, ..., <expr_n>])'.  Similarly, you can
collapse the elements of the array `A' by doing `collapse
(listarray ('A))'.

(%o1)                                true
(%i2) ```
Run Example
```collapse((a+1)>
(a+2));
(%o1)                            a + 1 > a + 2
(%i2) ```

### Related Help

Help for Collapse