# Question:Help with algsubs and derivative

## Question:Help with algsubs and derivative

Maple

# Hello!
# I've been trying to replace one expression into another, which includes the derivative of a quotient, but algsubs doesn't work and I don't know why.
# To make it simple, I want to replace a expression from rho into the expression for q_x. Let's say rho is a function of alpha.
>
> restart;
> alias(rho = rho(x, y, t)); alias(rho_an = rho_an(x, y, t));
> alias(p = p(x, y, t));
> alias(q_x = q_x(x, y, t));
> alias(alpha = alpha(x, y, t));
>
>
> rho_an := alpha;
> q_x := -k*(diff(p/(rho*R), x));
> algsubs(rho = rho_an, q_x);

-k*((diff(p, x))/(rho*R)-p*(diff(alpha, x))/(rho^2*R))

# Note that it replaces rho by alpha in the numerator, but not in the denominator.
# Actually, my expression for rho_an is more complicated : rho_an = rho_0 + rho_x * sin(a_x*pi*x/L) + rho_y*cos(a_y*pi*y/L)
# I tried using subs, and it replaces correctely, but it does not compute the derivative, which is needed.

>
> rho_an := rho_0+rho_x*sin(a_x*pi*x/L)+rho_y*cos(a_y*pi*y/L);
> algsubs(rho = rho_an, q_x);

-k*((diff(p, x))/(rho*R) - p*rho_x*cos(a_x*Pi*x/L)*a_x*Pi/(rho^2*R*L))