TransWikia.com

Replace multiple variables using a list?

Mathematica Asked by MichalCress on August 28, 2021

I want to calculate sum of derivatives
of expression

F = Exp[(x*z - 1) f*b + (x - 1) (1 - f) b]

from n-th to (n-k)-th, say k=4. The dummy way which works is:

der1 = D[F, {x, n}] + D[F, {x, k1}] + D[F, {x, k2}] + D[F, {x, k3}] + D[F, {x, k4}]
der1 = der1 /. {k1 -> n - 1, k2 -> n - 2, k3 -> n - 3, k4 -> n - 4}

However I’d like to do it automatically. I tried as follows:

der2 = Sum[D[F, {x, n - k}], {k, 0, 4}]

but the problem is that it doesn’t evaluate derivatives, leaving partial derivative symbol. Whereas the same method works if it is not (n-k)-th derivative but k-th derivative:

der3 = Sum[D[F, {x, k}], {k, 0, 4}]

My question is how to write der2 in order to give the same output as der1 but in the way of der3?
Sorry if question is stupid. Please note, I’m rather new to Mathematica.

One Answer

For a generic number of derivatives m, D does return a result

D[F, {x, m}]
E^(10*(1 - f)*(-1 + x) + 10*f*(-1 + x*z))*(10 - 10*f + 10*f*z)^m

I suppose Mathematica returns the partial derivatives, because it does not know whether your n is less than 4. There may be a way to solve this with appropriate assumptions, but in the meantime you could use some thing like

Sum[# /. {m -> n - k}, {k, 0, 4}]& @ D[F, {x, m}] // Simplify
10^(-4 + n) E^(10 (-1 + x + f x (-1 + z))) (1 + f (-1 + z))^(-4 + n) 
(11111 + 43210 f (-1 + z) + 63100 f^2 (-1 + z)^2 + 41000 f^3 (-1 + z)^3 +
10000 f^4 (-1 + z)^4)

Correct answer by Hausdorff on August 28, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP