# Rewriting an expression while using another parameter

I wish to rewrite V and M with the given A. I have provided what the end result is supposed to look like.

Here is V

V = -((S w δ μ + S γ δ μ + S δ μ^2 - V w γ δ σ)/(η (w + μ) (S + V σ) (μ + ψ)))


Here is M:

M = -((V w γ δ σ + V w δ μ σ + V γ δ μ σ + V δ μ^2 σ + S w δ ψ + S γ δ ψ +
S δ μ ψ + V w δ σ ψ + V γ δ σ ψ + V δ μ σ ψ)/(η (w + μ) (S + V σ) (μ + ψ)))


Here is the A:

A = (δ D (μ + γ))/(η (S + σ V))


Here is what the final form of V and M are supposed to look like:

V =  q/(μ + ψ) - A S/(D (μ + ψ))


and

M = W = (q ψ)/(μ (μ + ψ)) - A ψ Subscript[(S/(D μ (μ + ψ)) - σ A V/(D μ))


Sure I can use simplify on V and M and then manually manipulate by hand to get the end result but I am curious if this can be easily done in Mathematica. I have seen similar questions here but most of the ones I found people were just rewriting the entire expression in terms of another variable. Here I cannot rewrite V or M only in terms of A only so I think this is a little different.

• I formatted the Greek symbols but it appears there's something missing after Subscript in the last equation.
– JimB
Jun 17, 2022 at 17:45
• Your definition of $V$ contains $V$. Is this on purpose (a self-consistent definition)? Jun 17, 2022 at 18:11

Not a full solution but an attempt at simplifying semi-automatically.

Calculate the Gröbner basis to look for useful equations. We start with the three given equalities for $$V$$, $$M$$, and $$A$$,

V + ((S w δ μ + S γ δ μ + S δ μ^2 - V w γ δ σ)/(η (w + μ) (S + V σ) (μ + ψ))) == 0
M + ((V w γ δ σ + V w δ μ σ + V γ δ μ σ + V δ μ^2 σ + S w δ ψ + S γ δ ψ + S δ μ ψ + V w δ σ ψ + V γ δ σ ψ + V δ μ σ ψ)/(η (w + μ) (S + V σ) (μ + ψ))) == 0
A - (δ D (μ + γ))/(η (S + σ V)) == 0


and transform them into a whole set of functions that have the same zeros,

G = GroebnerBasis[{V + ((S w δ μ + S γ δ μ + S δ μ^2 - V w γ δ σ)/(η (w + μ) (S + V σ) (μ + ψ))),
M + ((V w γ δ σ + V w δ μ σ + V γ δ μ σ + V δ μ^2 σ + S w δ ψ + S γ δ ψ + S δ μ ψ + V w δ σ ψ + V γ δ σ ψ + V δ μ σ ψ)/(η (w + μ) (S + V σ) (μ + ψ))),
A - (δ D (μ + γ))/(η (S + σ V))},
{V, M, A}] // FullSimplify


Some of the resulting functions give simple expressions when solved for $$V$$ or $$M$$:

Solve[G[[8]] == 0, V] // FullSimplify
(*    {{V -> (-A S η + D δ (γ + μ))/(A η σ)}}    *)

Solve[G[[7]] == 0, M] // FullSimplify
(*    {{M -> -V - (δ (w + γ + μ))/(η (w + μ))}}    *)


So we have $$V=\frac{D\delta(\gamma+\mu)}{A\eta\sigma}-\frac{S}{\sigma}$$ and $$M=-V-\frac{\delta(\gamma+\mu+w)}{\eta(\mu+w)}$$. These aren't exactly the expression you were looking for, but already look pretty simple.

Also, we have

Solve[G[[5]] == 0, M] // FullSimplify
(*    {{M -> (-((D δ (γ + μ))/η) + A (S - (δ (w + γ + μ) σ)/(η (w + μ))))/(A σ)}}    *)


thus expressing M as a function of A without involving V: $$M=-\frac{D \delta(\gamma+\mu)}{A\eta\sigma}+\frac{S}{\sigma}-\frac{\delta(\gamma+\mu+w)}{\eta(\mu+w)}$$

Et cetera.

Clear["Global*"]


I have replaced D with d since D has a specific meaning within Mathematica.

eqns = {V == -((S w δ μ + S γ δ μ +
S δ μ^2 -
V w γ δ σ)/(η (w + μ) (S +
V σ) (μ + ψ))),
M == -((V w γ δ σ + V w δ μ σ +
V γ δ μ σ + V δ μ^2 σ +
S w δ ψ + S γ δ ψ +
S δ μ ψ + V w δ σ ψ +
V γ δ σ ψ +
V δ μ σ ψ)/(η (w + μ) (S +
V σ) (μ + ψ))),
A == (δ d (μ + γ))/(η (S + σ V))};


The requested forms cannot be obtained since they contain a variable q which is not contained in the original equations.

param = Complement[Variables[Level[eqns, {-1}]], {V, M, A}]

(* {d, S, w, γ, δ, η, μ, σ, ψ} *)

sol = Simplify[Solve[eqns, {V, M}, {#}][[1]] & /@ param];


Taking the solution with the lowest overall LeafCount

solVM = SortBy[sol, LeafCount][[1]]

(* {V -> (-A S η + d δ (γ + μ))/(A η σ),
M -> ((-A S η + d δ (γ + μ)) (-A σ +
d ψ))/(A d η μ σ)} *)


This gives the same result for V as the simplest (by LeafCount) expression for V among all of the solutions

solV = SortBy[sol[[All, 1]], LeafCount][[1]]

(* V -> (-A S η + d δ (γ + μ))/(A η σ) *)


However, there is a slightly simpler (by LeafCount) solution for M

solM = SortBy[sol[[All, 2]], LeafCount][[1]]

(* M -> (δ (w + γ + μ) (A σ -
d ψ))/(η (w + μ) (-A σ + d (μ + ψ))) *)

LeafCount /@ {solVM[[2]], solM}

(* {38, 36} *)
`