# Function to write an algebraic expression in terms of another

So I'm working on a physics problem. I have two functions:

$$\rho = \frac{F}{(\beta F^\alpha+1)^\frac{1}{\alpha}}$$, $$p = - \frac{F}{(\beta F^\alpha+1)^\frac{1}{\alpha}} + \frac{4}{3}\frac{F}{(\beta F^\alpha+1)^{1+\frac{1}{\alpha}}}$$

Just by looking at $$p$$, I can tell it can be algebraically manipulated in order to write it, explicitly, in terms of $$\rho$$. Indeed:

$$p= \frac{\rho}{3}(1-4\beta\rho^\alpha)$$

Every math operation I do by hand on this project, I check it on Mathematica just to make sure I don't screw it up. Sometimes I use functions like Simplify or FullSimplify to make my life easier. For example, if I use Simplify[$$\rho$$], I get a nice reduced expression, and the same for Simplify[$$p$$]. Nevertheless, I'd love for my program to write $$p$$ in terms of $$\rho$$ so I don't have to do it manually as I did above. I'm assuming a way to do this is to tell Mathematica to factor the explicit form of $$\rho$$ out of $$p$$, but I'm not sure. Either way, I haven't been able to do this (the factorizing). So far, I've read about the function FactorTerms and even an specific one shown in this answer, but none of this work as I want them to.

I'm assuming a function like this already exists or one may be defined simply, but I just can't figure it out. Any help is appreciated.

• Please edit your question to include a concrete example of what you are trying to do. Jan 24 at 2:41
• Hi @Vicente, and welcome to MSE! In addition to what Bob suggested, could you please include Mathematica's code for your functions, so that people don't need to retype it? Jan 24 at 4:01
• I can tell it can be algebraically manipulated are you sure? I just checked,. Your desired $d$ does not match. When I do it by hand, this is what I get !Mathematica graphics $$\rho \left(\frac{4}{3} \left(\frac{\rho }{F}\right)^{\alpha }-1\right)$$ Jan 24 at 4:31
• Copy-pasteable input? Without which this is not a viable question for this forum. Jan 24 at 5:13

ClearAll["Global*"]
ρ = F/(β*F^α + 1)^(1/α)
d = -(F/(β*F^α + 1)^((1/α))) + 4/3 F/(β*F^α + 1)^(1 + 1/α)
d /. (1 + F^α β) :> (F/HoldForm[ρ])^α
PowerExpand[%] // Simplify


Screen shot

V 13.2

# Solution

A more hands off approach, that still requires an guessed substitution, in this case

(β*F^α + 1) -> q


and then we eliminate q.

Also, I choose a somehow more verbose code to avoid lingering definitions and keep a clean kernel.

Surprisingly, not all combinations of Reduce, Eliminate and Solve work as effectively. These two options do work for this case:

## Eliminate (β*F^α + 1) by hand

Block[
{
q,
subs = ( (β*F^α + 1) -> q ), (* Put your intuition here *)
expre1 = ρ == F/(β*F^α + 1)^(1/α),
expre2 = d == (F/(β*F^α + 1)^((1/α))) + 4/3 F/(β*F^α + 1)^(1 + 1/α)
},
Assuming[
{F, β, α, ρ, q} ∈ PositiveReals,
FullSimplify[
expre2 /. subs /. Solve[expre1 /. subs, q]
]
]
]


## Eliminate (β*F^α + 1) using the third argument of Solve

Or also alternatively

Block[
{
q,
subs = ( (β*F^α + 1) -> q ), (* Put your intuition here *)
expre1 = ρ == F/(β*F^α + 1)^(1/α),
expre2 = d ==(F/(β*F^α + 1)^((1/α))) + 4/3 F/(β*F^α + 1)^(1 + 1/α)
},
Assuming[
{F, β, α, ρ, q} ∈ PositiveReals,
Solve[
Reduce[{expre2, expre1}/.subs]
, {d}
, {q} (* Undocumented "Eliminate" feature*)
, InverseFunctions->True
]
]
]
Simplify@%

• I'm asking further clarification about this undocumented way of evaluating Solve` in this other question. Jan 24 at 12:09