I have a fairly large expression that involves a lot of subexpressions of the form (100*A^3 + 200*A^2 + 100*A)*x
or (-A^2 - A)*y
or (100*A^2 + 100*A)*z
I know, but I don't know how to tell Maxima this, that it in this case is valid to make the approximation A+1 ~ A
, thereby effectively removing anything but the highest power of A
in each coefficient.
I'm now looking for functions, tools, or methods that I can use to guide Maxima in dropping various terms that aren't important.
I have attempted with subst
, but that requires me to specify each and every factor separately, because:
subst([A+1=B], (A+2)*(A+1)*2);
subst([A+1=B], (A+2)*(A*2+2));
(%o1) 2*(A+2)*B
(%o2) (A+2)*(2*A+2)
(that is, I need to add one expression for each slightly different variant)
I tried with ratsimp
, but that's too eager to change every occurrence:
ratsubst(B, A+1, A*(A+1)*2);
ratsubst(B, A+1, A*(A*2+2));
(%o3) 2*B^2-2*B
(%o4) 2*B^2-2*B
which isn't actually simpler, as I would have preferred the answer to have been given as 2*B^2
.
In another answer, (https://stackoverflow.com/a/22695050/5999883) the functions let
and letsimp
were suggested for the task of substituting values, but I fail to get them to really do anything:
x:(A+1)*A;
let ( A+1, B );
letsimp(x);
(x)A*(A+1)
(%o6) A+1 --\> B
(%o7) A^2+A
Again, I'd like to approximate this expression to A^2
(B^2
, whatever it's called).
I understand that this is, in general, a hard problem (is e.g. A^2 + 10^8*A
still okay to approximate as A^2
?) but I think that what I'm looking for is a function or method of calculation that would be a little bit smarter than subst
and can recognize that the same substitution could be done in the expression A^2+A
as in the expression 100*A^2+100*A
or -A^2-A
instead of making me create a list of three (or twenty) individual substitutions when calling subst
. The "nice" part of the full expression that I'm working on is that each of these A
factors are of the form k*A^n*(A+1)^m
for various small integers n
, m
, so I never actually end up with the degenerate case mentioned above.
(I was briefly thinking of re-expressing my expression as a polynomial in A
, but this will not work as the only valid approximation of the expression (A^3+A^2+A)*x + y
is A^3*x + y
-- I know nothing about the relative sizes of x
and y
.