2
$\begingroup$

EDIT: Would it be possible to do something like let $y=ax+b$ then use Collect[] or Apart[] on the new expression? How would I go about this. I've tried using Collect[%,ax+b], Collect[%,{ax+b}], and the same for Apart[] but it doens't work.


I have equations such as this:

Latex: $225 a^4 + 600 a^3 b^2 + 520 a^2 b^4 + 160 a b^6 + 16 b^8 + 1200 a^4 b x + 2080 a^3 b^3 x + 960 a^2 b^5 x + 128 a b^7 x + 600 a^5 x^2 + 3120 a^4 b^2 x^2 + 2400 a^3 b^4 x^2 + 448 a^2 b^6 x^2 + 2080 a^5 b x^3 + 3200 a^4 b^3 x^3 + 896 a^3 b^5 x^3 + 520 a^6 x^4 + 2400 a^5 b^2 x^4 + 1120 a^4 b^4 x^4 + 960 a^6 b x^5 + 896 a^5 b^3 x^5 + 160 a^7 x^6 + 448 a^6 b^2 x^6 + 128 a^7 b x^7 + 16 a^8 x^8$

Mathematica: 225 a^4 + 600 a^3 b^2 + 520 a^2 b^4 + 160 a b^6 + 16 b^8 + 1200 a^4 b x + 2080 a^3 b^3 x + 960 a^2 b^5 x + 128 a b^7 x + 600 a^5 x^2 + 3120 a^4 b^2 x^2 + 2400 a^3 b^4 x^2 + 448 a^2 b^6 x^2 + 2080 a^5 b x^3 + 3200 a^4 b^3 x^3 + 896 a^3 b^5 x^3 + 520 a^6 x^4 + 2400 a^5 b^2 x^4 + 1120 a^4 b^4 x^4 + 960 a^6 b x^5 + 896 a^5 b^3 x^5 + 160 a^7 x^6 + 448 a^6 b^2 x^6 + 128 a^7 b x^7 + 16 a^8 x^8

which has an awesome simplified form that I did by hand as:

Latex: $(15a^2 + 20a(ax+b)^2 + 4(ax+b)^4)^2$

Mathematica: (15a^2 + 20a(ax+b)^2 + 4(ax+b)^4)^2

However, these get much more difficult when I deal with things like (Note: I have hundreds of expressions like this, so I need general help with the types of expressions to get things in an alternate form, not just this one done) :

Latex: $108056025 a^{10} + 720373500 a^9 b^2 + 1776921300 a^8 b^4 + 2085652800 a^7 b^6 + 1335549600 a^6 b^8 + 500734080 a^5 b^{10} + 113731200 a^4 b^{12} + 15713280 a^3 b^{14} + 1281280 a^2 b^{16} + 56320 a b^{18} + 1024 b^{20} + 1440747000 a^{10} b x + 7107685200 a^9 b^3 x + 12513916800 a^8 b^5 x + 10684396800 a^7 b^7 x + 5007340800 a^6 b^9 x + 1364774400 a^5 b^{11} x + 219985920 a^4 b^{13} x + 20500480 a^3 b^{15} x + 1013760 a^2 b^{17} x + 20480 a b^{19} x + 720373500 a^{11} x^2 + 10661527800 a^{10} b^2 x^2 + 31284792000 a^9 b^4 x^2 + 37395388800 a^8 b^6 x^2 + 22533033600 a^7 b^8 x^2 + 7506259200 a^6 b^{10} x^2 + 1429908480 a^5 b^{12} x^2 + 153753600 a^4 b^{14} x^2 + 8616960 a^3 b^{16} x^2 + 194560 a^2 b^{18} x^2 + 7107685200 a^{11} b x^3 + 41713056000 a^{10} b^3 x^3 + 74790777600 a^9 b^5 x^3 + 60088089600 a^8 b^7 x^3 + 25020864000 a^7 b^9 x^3 + 5719633920 a^6 b^{11} x^3 + 717516800 a^5 b^{13} x^3 + 45957120 a^4 b^{15} x^3 + 1167360 a^3 b^{17} x^3 + 1776921300 a^{12} x^4 + 31284792000 a^{11} b^2 x^4 + 93488472000 a^{10} b^4 x^4 + 105154156800 a^9 b^6 x^4 + 56296944000 a^8 b^8 x^4 + 15728993280 a^7 b^{10} x^4 + 2331929600 a^6 b^{12} x^4 + 172339200 a^5 b^{14} x^4 + 4961280 a^4 b^{16} x^4 + 12513916800 a^{12} b x^5 + 74790777600 a^{11} b^3 x^5 + 126184988160 a^{10} b^5 x^5 + 90075110400 a^9 b^7 x^5 + 31457986560 a^8 b^9 x^5 + 5596631040 a^7 b^{11} x^5 + 482549760 a^6 b^{13} x^5 + 15876096 a^5 b^{15} x^5 + 2085652800 a^{13} x^6 + 37395388800 a^{12} b^2 x^6 + 105154156800 a^{11} b^4 x^6 + 105087628800 a^{10} b^6 x^6 + 47186979840 a^9 b^8 x^6 + 10260490240 a^8 b^{10} x^6 + 1045524480 a^7 b^{12} x^6 + 39690240 a^6 b^{14} x^6 + 10684396800 a^{13} b x^7 + 60088089600 a^{12} b^3 x^7 + 90075110400 a^{11} b^5 x^7 + 53927976960 a^{10} b^7 x^7 + 14657843200 a^9 b^9 x^7 + 1792327680 a^8 b^{11} x^7 + 79380480 a^7 b^{13} x^7 + 1335549600 a^{14} x^8 + 22533033600 a^{13} b^2 x^8 + 56296944000 a^{12} b^4 x^8 + 47186979840 a^{11} b^6 x^8 + 16490073600 a^{10} b^8 x^8 + 2464450560 a^9 b^{10} x^8 + 128993280 a^8 b^{12} x^8 + 5007340800 a^{14} b x^9 + 25020864000 a^{13} b^3 x^9 + 31457986560 a^{12} b^5 x^9 + 14657843200 a^{11} b^7 x^9 + 2738278400 a^{10} b^9 x^9 + 171991040 a^9 b^{11} x^9 + 500734080 a^{15} x^{10} + 7506259200 a^{14} b^2 x^{10} + 15728993280 a^{13} b^4 x^{10} + 10260490240 a^{12} b^6 x^{10} + 2464450560 a^{11} b^8 x^{10} + 189190144 a^{10} b^{10} x^{10} + 1364774400 a^{15} b^3 x^{11} + 5719633920 a^{14} b^3 x^{11} + 5596631040 a^{13} b^5 x^{11} + 1792327680 a^{12} b^7 x^{11} + 171991040 a^{11} b^9 x^{11} + 113731200 a^{16} x^{12} + 1429908480 a^{15} b^2 x^{12} + 2331929600 a^{14} b^4 x^{12} + 1045524480 a^{13} b^6 x^{12} + 128993280 a^{12} b^8 x^{12} + 219985920 a^{16} b x^{13} + 717516800 a^{15} b^3 x^{13} + 482549760 a^{14} b^5 x^{13} + 79380480 a^{13} b^7 x^{13} + 15713280 a^{17} x^{14} + 153753600 a^{16} b^2 x^{14} + 172339200 a^{15} b^4 x^{14} + 39690240 a^{14} b^6 x^{14} + 20500480 a^{17} b x^{15} + 45957120 a^{16} b^3 x^{15} + 15876096 a^{15} b^5 x^{15} + 1281280 a^{18} x^{16} + 8616960 a^{17} b^2 x^{16} + 4961280 a^{16} b^4 x^{16} + 1013760 a^{18} b x^{17} + 1167360 a^{17} b^3 x^{17} + 56320 a^{19} x^{18} + 194560 a^{18} b^2 x^{18} + 20480 a^{19} b x^{19} + 1024 a^{20} x^{20}$

Mathematica: 108056025 a^10 + 720373500 a^9 b^2 + 1776921300 a^8 b^4 + 2085652800 a^7 b^6 + 1335549600 a^6 b^8 + 500734080 a^5 b^10 + 113731200 a^4 b^12 + 15713280 a^3 b^14 + 1281280 a^2 b^16 + 56320 a b^18 + 1024 b^20 + 1440747000 a^10 b x + 7107685200 a^9 b^3 x + 12513916800 a^8 b^5 x + 10684396800 a^7 b^7 x + 5007340800 a^6 b^9 x + 1364774400 a^5 b^11 x + 219985920 a^4 b^13 x + 20500480 a^3 b^15 x + 1013760 a^2 b^17 x + 20480 a b^19 x + 720373500 a^11 x^2 + 10661527800 a^10 b^2 x^2 + 31284792000 a^9 b^4 x^2 + 37395388800 a^8 b^6 x^2 + 22533033600 a^7 b^8 x^2 + 7506259200 a^6 b^10 x^2 + 1429908480 a^5 b^12 x^2 + 153753600 a^4 b^14 x^2 + 8616960 a^3 b^16 x^2 + 194560 a^2 b^18 x^2 + 7107685200 a^11 b x^3 + 41713056000 a^10 b^3 x^3 + 74790777600 a^9 b^5 x^3 + 60088089600 a^8 b^7 x^3 + 25020864000 a^7 b^9 x^3 + 5719633920 a^6 b^11 x^3 + 717516800 a^5 b^13 x^3 + 45957120 a^4 b^15 x^3 + 1167360 a^3 b^17 x^3 + 1776921300 a^12 x^4 + 31284792000 a^11 b^2 x^4 + 93488472000 a^10 b^4 x^4 + 105154156800 a^9 b^6 x^4 + 56296944000 a^8 b^8 x^4 + 15728993280 a^7 b^10 x^4 + 2331929600 a^6 b^12 x^4 + 172339200 a^5 b^14 x^4 + 4961280 a^4 b^16 x^4 + 12513916800 a^12 b x^5 + 74790777600 a^11 b^3 x^5 + 126184988160 a^10 b^5 x^5 + 90075110400 a^9 b^7 x^5 + 31457986560 a^8 b^9 x^5 + 5596631040 a^7 b^11 x^5 + 482549760 a^6 b^13 x^5 + 15876096 a^5 b^15 x^5 + 2085652800 a^13 x^6 + 37395388800 a^12 b^2 x^6 + 105154156800 a^11 b^4 x^6 + 105087628800 a^10 b^6 x^6 + 47186979840 a^9 b^8 x^6 + 10260490240 a^8 b^10 x^6 + 1045524480 a^7 b^12 x^6 + 39690240 a^6 b^14 x^6 + 10684396800 a^13 b x^7 + 60088089600 a^12 b^3 x^7 + 90075110400 a^11 b^5 x^7 + 53927976960 a^10 b^7 x^7 + 14657843200 a^9 b^9 x^7 + 1792327680 a^8 b^11 x^7 + 79380480 a^7 b^13 x^7 + 1335549600 a^14 x^8 + 22533033600 a^13 b^2 x^8 + 56296944000 a^12 b^4 x^8 + 47186979840 a^11 b^6 x^8 + 16490073600 a^10 b^8 x^8 + 2464450560 a^9 b^10 x^8 + 128993280 a^8 b^12 x^8 + 5007340800 a^14 b x^9 + 25020864000 a^13 b^3 x^9 + 31457986560 a^12 b^5 x^9 + 14657843200 a^11 b^7 x^9 + 2738278400 a^10 b^9 x^9 + 171991040 a^9 b^11 x^9 + 500734080 a^15 x^10 + 7506259200 a^14 b^2 x^10 + 15728993280 a^13 b^4 x^10 + 10260490240 a^12 b^6 x^10 + 2464450560 a^11 b^8 x^10 + 189190144 a^10 b^10 x^10 + 5719633920 a^14 b^3 x^11 + 1364774400 a^15 b^3 x^11 + 5596631040 a^13 b^5 x^11 + 1792327680 a^12 b^7 x^11 + 171991040 a^11 b^9 x^11 + 113731200 a^16 x^12 + 1429908480 a^15 b^2 x^12 + 2331929600 a^14 b^4 x^12 + 1045524480 a^13 b^6 x^12 + 128993280 a^12 b^8 x^12 + 219985920 a^16 b x^13 + 717516800 a^15 b^3 x^13 + 482549760 a^14 b^5 x^13 + 79380480 a^13 b^7 x^13 + 15713280 a^17 x^14 + 153753600 a^16 b^2 x^14 + 172339200 a^15 b^4 x^14 + 39690240 a^14 b^6 x^14 + 20500480 a^17 b x^15 + 45957120 a^16 b^3 x^15 + 15876096 a^15 b^5 x^15 + 1281280 a^18 x^16 + 8616960 a^17 b^2 x^16 + 4961280 a^16 b^4 x^16 + 1013760 a^18 b x^17 + 1167360 a^17 b^3 x^17 + 56320 a^19 x^18 + 194560 a^18 b^2 x^18 + 20480 a^19 b x^19 + 1024 a^20 x^20

Where full simplifying gives this:

1024 b^20 + 1024 a^20 x^20 + 5120 a b^18 (11 + 4 b x) + 5120 a^19 x^18 (11 + 4 b x) + 1280 a^2 b^16 (1001 + 8 b x (99 + 19 b x)) + 1280 a^18 x^16 (1001 + 8 b x (99 + 19 b x)) + 5120 a^3 b^14 (3069 + b x (4004 + 3 b x (561 + 76 b x))) + 5120 a^17 x^14 (3069 + b x (4004 + 3 b x (561 + 76 b x))) + 1920 a^4 b^12 (59235 + 8 b x (14322 + b x (10010 + 17 b x (176 + 19 b x)))) + 1920 a^16 x^12 (59235 + 8 b x (14322 + b x (10010 + 17 b x (176 + 19 b x)))) + 128 a^5 b^10 (3911985 + 4 b x (2665575 + 2 b x (1396395 + 4 b x (175175 + 51 b x (825 + 76 b x))))) + 128 a^15 x^10 (3911985 + 4 b^2 x (2792790 x + b (2665575 + 8 x^2 (175175 + 51 b x (825 + 76 b x))))) + 160 a^6 b^8 (8347185 + 8 b x (3911985 + b x (5864265 + 4 b x (1117116 + b x (455455 + 408 b x (231 + 19 b x)))))) + 160 a^14 x^8 (8347185 + 8 b x (3911985 + b x (5864265 + 4 b x (1117116 + b x (455455 + 408 b x (231 + 19 b x)))))) + 960 a^7 b^6 (2172555 + 2 b x (5564790 + b x (11735955 + 4 b x (3257925 + 2 b x (1024023 + 4 b x (91091 + 17 b x (1001 + 76 b x))))))) + 960 a^13 x^6 (2172555 + 2 b x (5564790 + b x (11735955 + 4 b x (3257925 + 2 b x (1024023 + 4 b x (91091 + 17 b x (1001 + 76 b x))))))) + 20 a^8 b^4 (88846065 + 32 b x (19552995 + b x (58430295 + b x (93887640 + b x (87963975 + 208 b x (236313 + b x (77077 + 51 b x (264 + 19 b x)))))))) + 20 a^12 x^4 (88846065 + 32 b x (19552995 + b x (58430295 + b x (93887640 + b x (87963975 + 208 b x (236313 + b x (77077 + 51 b x (264 + 19 b x)))))))) + 20 a^9 b^2 (36018675 + 4 b x (88846065 + 4 b x (97764975 + 4 b x (58430295 + b x (82151685 + 4 b x (17592795 + 13 b x (708939 + 2 b x (110110 + 17 b x (1089 + 76 b x))))))))) + 20 a^11 x^2 (36018675 + 4 b x (88846065 + 4 b x (97764975 + 4 b x (58430295 + b x (82151685 + 4 b x (17592795 + 13 b x (708939 + 2 b x (110110 + 17 b x (1089 + 76 b x))))))))) + 11 a^10 (9823275 + 8 b x (16372125 + b x (121153725 + 8 b x (59251500 + b x (132796125 + 8 b x (22405005 + b x (18659025 + 13 b x (736560 + b x (225225 + 136 b x (275 + 19 b x))))))))))

So as you can see I need a way to simplify it in a similar way. However, I'm having trouble finding a way to get mathematica to simplify it in this way. Any suggestions? Also is there a list of all the ways I can simplify expressions? I have been going to the mathematica site and just looking at similar expressions to "simplify", "expand", "part", "apart", etc...

$\endgroup$
  • $\begingroup$ Why would you ever simplify a complex equation "by hand"? Try FullSimplify[]. If you post your equation in Mathematica (not $\LaTeX$) form we can try to help you. $\endgroup$ – David G. Stork Jul 10 '15 at 18:29
  • $\begingroup$ @DavidG.Stork Because FullSimplify[] just factors it out as it sees fit and it's REALLY ugly for stuff like this. It turns into something along the lines of (a + b(c +d(e + f(g + h(i + j(.....)))))))))) rather than a nice form as I have above. I'm just looking for the correct expression to simplify it in the same way as I have above if it exists. I'll edit original post to include the mathematica text for the first two expressions. $\endgroup$ – Kvothealar Jul 10 '15 at 19:45
  • $\begingroup$ Simplify[] on your first big expression gives your "hand" result in less than a second. (Again, why would one ever slog through such a problem "by hand"?) If you post the Mathematica form of your big expression, we can perhaps help you. $\endgroup$ – David G. Stork Jul 10 '15 at 20:26
  • 1
    $\begingroup$ I can't get the first one to reduce into the expression I have up there at all though. I get (4 b^4 + 4 a^4 x^4 + 4 a b^2 (5 + 4 b x) + 4 a^3 x^2 (5 + 4 b x) + a^2 (15 + 40 b x + 24 b^2 x^2))^2 I'll post the mathematica code for the large one. $\endgroup$ – Kvothealar Jul 13 '15 at 11:32
  • $\begingroup$ @Kvothealar I don't know why your question got a cold reception. I like it. Unlike some similar questions where the desired form is not actually simpler or where it is only equivalent under certain assumptions this appears to be a case where FullSimplify fails to produce a result as good as your own. I think it is useful to explore how this might be improved. $\endgroup$ – Mr.Wizard Jul 15 '15 at 13:52
3
$\begingroup$
e1 = 225 a^4 + 600 a^3 b^2 + 520 a^2 b^4 + 160 a b^6 + 16 b^8 + 
   1200 a^4 b x + 2080 a^3 b^3 x + 960 a^2 b^5 x + 128 a b^7 x + 
   600 a^5 x^2 + 3120 a^4 b^2 x^2 + 2400 a^3 b^4 x^2 + 
   448 a^2 b^6 x^2 + 2080 a^5 b x^3 + 3200 a^4 b^3 x^3 + 
   896 a^3 b^5 x^3 + 520 a^6 x^4 + 2400 a^5 b^2 x^4 + 
   1120 a^4 b^4 x^4 + 960 a^6 b x^5 + 896 a^5 b^3 x^5 + 160 a^7 x^6 + 
   448 a^6 b^2 x^6 + 128 a^7 b x^7 + 16 a^8 x^8;

then

e1 /. x -> (y - b)/a // Expand // Factor

(15 a^2 + 20 a y^2 + 4 y^4)^2

$\endgroup$
  • $\begingroup$ This is great! Thank you so much! You and Mr. Wizard have very similar solutions to this problem however there is an extra step added into his. Would you be able to comment on the difference? I'm still fairly new to Mathematica. $\endgroup$ – Kvothealar Jul 15 '15 at 18:12
  • $\begingroup$ @Kvothealar I just made a change of variables e1 /. x -> (y - b)/a, then I expanded the expression e1 /. x -> (y - b)/a // Expand, then factorized the resulting polynomial e1 /. x -> (y - b)/a // Expand // Factor. Try to run each of these 3 commands separately to see what happens step by step. Maybe you are not familiar with the // notation : the whole sequence can also be written Expand[Factor[e1 /. x -> (y - b)/a]]. And /. is a shorthand for the function ReplaceAll. I'll let Mr.Wizard comment on his solution, but you can read also the docs for the function Reduce. $\endgroup$ – SquareOne Jul 15 '15 at 22:54
  • $\begingroup$ @Kvothealar By the way, you can also do this : e1 /. x -> (y - b)/a // FullSimplify. For your second longer expression it even gives a more interesting result. $\endgroup$ – SquareOne Jul 15 '15 at 22:58
  • $\begingroup$ It certainly does. I have some rather large ones and I am finding it very difficult to get them to fit on the page using the Expand // Factor. But using FullSimplify gives me a few terms to throw around, even if the expression is longer afterwards. Thanks so much for the help haha! $\endgroup$ – Kvothealar Jul 17 '15 at 2:29
2
$\begingroup$

FullSimplify[] on the enormous expression gives this answer in less than a second:

$(4 b^4 + 4 a^4 x^4 + 4 a b^2 (5 + 4 b x) + 4 a^3 x^2 (5 + 4 b x) + a^2 (15 + 8 b x (5 + 3 b x)))^2$

It would take me several days to calculate such a result "by hand," and no doubt I would make errors.

$\endgroup$
  • 1
    $\begingroup$ That's what I got for the small expression. I don't like this form though because it can be represented in linear combinations of the even powers of (ax+b). Doing that expression by hand took me about 5 minutes, just grouping everything in terms of how many combined a's and b's I had. (Like if I have a whole bunch of terms where a^n b^m where n+m=8, then I know it's some constant multiplied by the 9th row of Pascals triangle). But I don't want to attempt the larger expression. $\endgroup$ – Kvothealar Jul 13 '15 at 11:36
2
$\begingroup$

This is not a robust solution but since no one else was motivated to try to match your result here's my rough draft.

expr1 = 225 a^4 + 600 a^3 b^2 + 520 a^2 b^4 + 160 a b^6 + 16 b^8 + 1200 a^4 b x + 
   2080 a^3 b^3 x + 960 a^2 b^5 x + 128 a b^7 x + 600 a^5 x^2 + 3120 a^4 b^2 x^2 + 
   2400 a^3 b^4 x^2 + 448 a^2 b^6 x^2 + 2080 a^5 b x^3 + 3200 a^4 b^3 x^3 + 
   896 a^3 b^5 x^3 + 520 a^6 x^4 + 2400 a^5 b^2 x^4 + 1120 a^4 b^4 x^4 + 960 a^6 b x^5 + 
   896 a^5 b^3 x^5 + 160 a^7 x^6 + 448 a^6 b^2 x^6 + 128 a^7 b x^7 + 16 a^8 x^8;

id /. ToRules @ Reduce[{expr1 == id, zz == (b + a x)}, id, b] // Quiet

% /. zz -> (b + a x)
(15 a^2 + 20 a zz^2 + 4 zz^4)^2

(15 a^2 + 20 a (b + a x)^2 + 4 (b + a x)^4)^2

id and zz are just arbitrary placeholders for the transformation.

Applying the same process to your second expression gives:

108056025 a^10 + 1364774400 a^16 x^12 - 1364774400 a^18 x^14 - 
 1364774400 a^15 x^11 (b + a x) + 4094323200 a^17 x^13 (b + a x) + 
 720373500 a^9 (b + a x)^2 - 4094323200 a^16 x^12 (b + a x)^2 + 
 1364774400 a^15 x^11 (b + a x)^3 + 1776921300 a^8 (b + a x)^4 + 
 2085652800 a^7 (b + a x)^6 + 1335549600 a^6 (b + a x)^8 + 500734080 a^5 (b + a x)^10 + 
 113731200 a^4 (b + a x)^12 + 15713280 a^3 (b + a x)^14 + 1281280 a^2 (b + a x)^16 + 
 56320 a (b + a x)^18 + 1024 (b + a x)^20
$\endgroup$
  • $\begingroup$ Thanks for your feedback above! I've been sitting at my desk unable to work until I figured out this problem or did it all by hand so I really appreciate this! I noticed that your answer and SquareOne's answer differed in that you had this line {{{ id /. ToRules @ Reduce[{expr1 == id, zz == (b + a x)}, id, b] // Quiet }}}. I'm still somewhat of a newbie when it comes to Mathematica, could you explain what this step does and why you chose to include it? $\endgroup$ – Kvothealar Jul 15 '15 at 17:04
  • $\begingroup$ @Kvothealar You are welcome. SquareOne's method is surely simpler if it works in all cases; it is probably the better answer. I simply wanted to get some ink on the page. If you're brave ;-) consider following all the links in this answer. Hopefully your problem is simpler than many of those but I think you should be aware of those efforts. $\endgroup$ – Mr.Wizard Jul 16 '15 at 0:24
  • $\begingroup$ I will certainty have a look at it when I get the chance! Thanks so much! $\endgroup$ – Kvothealar Jul 17 '15 at 2:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.