1
$\begingroup$

I have the following relations:

Dc == k*t0^2
Dp == k*t1^2

I know that I can do the following:

$\qquad \frac{D_c}{k\space t_0^2}==1 \quad \frac{D_p}{k\space t_1^2}==1 \quad \frac{D_c}{k\space t_0^2}==\frac{D_p}{k\space t_1^2} \quad D_c==\frac{t_0^2}{t_1^2}D_p$

How can I tell Mathematica to do the same thing? That is, given two equations, how do I coerce Mathematica to come up with a value of $D_c$?

$\endgroup$
6
  • 3
    $\begingroup$ eqns = {Dc == k*t0^2, Dp == k*t1^2}; sol = Solve[eqns, Dc, {k}][[1]] $\endgroup$
    – Bob Hanlon
    May 25, 2020 at 22:06
  • $\begingroup$ @BobHanlon - Your solution appears to work, but I can't explain how. I tried Solve, but with just two parameters. The third parameter is the domain. How is ${\alpha}$ a domain? If you post this as an answer, I'll up-vote it. $\endgroup$
    – Quark Soup
    May 25, 2020 at 23:13
  • 4
    $\begingroup$ Solve accepts an optional argument to designate variable(s) to be eliminated. This argument must be a List even with a single variable so that the argument is not interpreted as an attempt to specify a domain. The number of variables to solve for plus the number of variables to be eliminated must equal the number of equations. In this case with two equations, you must either solve for two variables or solve for one variable and eliminate one variable. $\endgroup$
    – Bob Hanlon
    May 25, 2020 at 23:44
  • $\begingroup$ I was unaware of that feature of the Solve function as it doesn't appear in the help. This is my favorite answer as it seems to be the most direct. $\endgroup$
    – Quark Soup
    May 26, 2020 at 0:13
  • 1
    $\begingroup$ Yes, that feature of Solve[] used to be documented; now it isn't. $\endgroup$ May 26, 2020 at 15:18

2 Answers 2

2
$\begingroup$

Strictly speaking you are eliminating $k$ and you don't need Solve. This is what Eliminate is for and it will also generate conditions on $t_0,t_1$:

Eliminate[{Dc == k*t0^2 , Dp == k*t1^2, Dc/(k t0 ^2) == Dp/(k t1^2)}, k]

(* Dc == (Dp t0^2)/t1^2 && t0 != 0 && t1 != 0 *)
$\endgroup$
2
  • $\begingroup$ How am I supposed to extract the answer from that? My eyes can see it, but how do I tell a program to extract just the ratio of $\frac{t0^2}{t1^2}$ from that? $\endgroup$
    – Quark Soup
    May 25, 2020 at 23:31
  • $\begingroup$ You didn't express that's what you wanted in the original question, but in that case John Doty's answer handles this. You would use Replace. $\endgroup$
    – flinty
    May 26, 2020 at 10:58
2
$\begingroup$

You apparently want to eliminate k and solve for Dc, so

Solve[Eliminate[Dc == k*t0^2 && Dp == k*t1^2, k], Dc]
(* {{Dc -> (Dp t0^2)/t1^2}} *)
$\endgroup$
3
  • $\begingroup$ Seems like I need to know ahead of time that $k$ can be eliminated. I was hoping I could just set up the relations and have Mathematica figure out what needed to be eliminated. $\endgroup$
    – Quark Soup
    May 25, 2020 at 23:33
  • 3
    $\begingroup$ The trouble is that you already have Dc == k*t0^2, so that's a perfectly good solution. If you want a different solution, you have to somehow specify what it is that you want. With two equations, you get to solve for two variables. So, pick your variables and parameters. If you don't care about a variable, eliminate it. Mathematica can't read your mind here. $\endgroup$
    – John Doty
    May 25, 2020 at 23:41
  • 2
    $\begingroup$ @Quarkly - Without context, you could just as easily want to eliminate Dp, t1, or t2. $\endgroup$
    – Bob Hanlon
    May 25, 2020 at 23:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.