Basic Examples (4)
Basic Examples
(4)
Choose an expression:
In[1]:=
expr=(#1〚1,2〛&)/@Solve[8+42+64+71x+270,x,QuarticsTrue];
4
x
3
x
2
x
Get a list of replacements to rewrite the expression:
In[2]:=
optexpr=[expr]
Out[2]=
c58,c1-9032,c2-,c3-,c4-1,c5-,c6-,c7-,c8-,c9-,c10,c11,c12,c13,c142,c153,c16,c178,c18,c19,c20299,c2146535,c22560405067,c23,c24,c25,c26c15c25,c27c21+c26,c28,c29,c30c14c27,c31,c32,c33c1c23c29,c34c8c24c28,c35c17c31,c36c18c32,c37c20+c33+c35,c38,c39c15c38,c40,c41,c42c10c41,c43c19c40,c44c2c40,c45c9c41,c46c16+c34+c36+c43,c47c16+c34+c36+c44,c48,c49,c50c12c48,c51c12c49,c52c6c48,c53c6c49,c54c3+c42+c51,c55c3+c42+c53,c56c3+c45+c50,c57c3+c45+c52,c58{c55,c54,c57,c56}
3053
32
21
16
2
3
1
2
1
3
1
12
1
16
1
16
1
3
1
2
2
3
299
96
1129
12
3053
32
c13
c14
c5
c14
c12
c22
c11
c27
c7
c27
c11
c30
c7
c30
c4
c37
c12
c39
c6
c39
c12
c46
c12
c47
In[3]:=
ReplaceRepeated@@%//Short
Out[3]//Short=
-+--+-,2,1
21
16
1
1
1
2
299
96
1
1
121
4
1
3053
32
3
299-1+8
1
1
Recover the original expression, applying replacements only six times, starting with the final string:
In[1]:=
expr2=Nest[#/.Last[optexpr]&,"c58",6]
Out[1]=
-+-+c18c32+c2c40+c24c28c8,-+++c18c32+c2c40+c24c28c8,---+c18c32+c19c40+c24c28c8,--++c18c32+c19c40+c24c28c8
21
16
1
16
3
c4
c37
1
2
299
96
21
16
1
16
3
c4
c37
1
2
299
96
21
16
1
16
3
c4
c37
1
2
299
96
21
16
1
16
3
c4
c37
1
2
299
96
In[1]:=
ResourceFunction["FromRecursiveRewrite"][expr2[[1]],Last[optexpr],Tooltip[Framed[#1,BackgroundGrayLevel[.95]],#2]&]
Out[1]=
-+-+++
21
16
1
16
3
1
2
299
96
Scope (1)
Scope
(1)
Options (4)
Options
(4)
Possible Issues (1)
Possible Issues
(1)