# [Maxima] ratsubst within logarithm

Rupert Swarbrick rswarbrick at gmail.com
Thu Apr 5 05:34:43 CDT 2012

Tamas Papp <tkpapp at gmail.com> writes:
> Hi,
>
> If I do
>
> texput(%lambda,"\\lambda");
> assume(%lambda > 0);
> integrate(1/(1+A*exp(%lambda*(p-s))),p,x,inf);
>
> I get an expression where x-s always occurs together, so it would be
> convenient to replace them by a single parameter y=x-s.  I tried
>
> ratsubst(y,x-s,%);
>
> but the substitution is not performed inside the logarithm.  Is there
> a way I could make Maxima simplify this?  I guess I need to cancel the
> exp(something)*exp(-something) terms first inside the log, but I don't
> know how.

There's a slight work-around that I generally use in this sort of
situation. Instead substitute y+s for x:

(%i1) assume(λ > 0);
(%o1)                               [λ > 0]
(%i2) assume(A > 0);
(%o2)                               [A > 0]
(%i3) integrate(1/(1+A*exp(λ*(p-s))),p,x,inf);
Is s λ an integer?

no;
- s λ      x λ     s λ
log(%e      (A %e    + %e   ))   log(A)
(%o3)           ------------------------------ - ------ - x + s
λ                    λ
(%i4) subst(y+s, x, %);
- s λ      (y + s) λ     s λ
log(%e      (A %e          + %e   ))   log(A)
(%o4)          ------------------------------------ - ------ - y
λ                       λ
(%i5) factor(%);
y λ
log(A %e    + 1) - y λ - log(A)
(%o5)                   -------------------------------
λ

I'm not sure how to convince ratsubst to deal with the exponentials
correctly: my attempts with map and scanmap failed miserably. Anyone got
any suggestions?

Rupert
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 315 bytes
Desc: not available
URL: <http://www.math.utexas.edu/pipermail/maxima/attachments/20120405/f6472c94/attachment.pgp>