# meyerweb.com

### Seeking Math Help

So I have this equation that’s great for finding one term.  Problem is, I need to solve for another term that’s scattered all across the right side.  I’m hoping someone here has the mad algebra skills I managed to lose in the two decades since I last took a math class and can help me out.

Here’s the original equation:

Q = (3.07 × F × Y × (1 + 1.4 × ((D/V) × e(-2 × D/V)))) / D2

I want to be able to solve for D, not Q; in other words, have a single D on the left and everything else on the right of the equation.  F, Y, and V are all variable terms; the e is the classic irrational constant.  I tried for quite a while to do this and ran very firmly aground.  The best I managed was this minor simplification:

Q = (3.07 × F × Y × (1 + 1.4 × (D / (V × e(2 × D/V)))) / D2

…and even that assumes that I did things correctly.  Here’s the original equation in pretty shoulda-done-it-in-MathML-but-oh-well form:

I can shuffle the chairs around, as it were, but never really get anywhere close to having a single D on the left.  “But it’s so easy!“, you may well be shouting.  That’s why you’re working for Google and I’m not.

I remember having questions just like this on tests back in college: “Given this equation, solve for blah”.  It’s been too long, though, and in all honesty I was never that great at this sort of thing in the first place. Help, please?

[Update 14 Jan 09]: several commenters have shown that what I’m trying to do is impossible.  Frustrating, but that’s math for you.  Looks like I’ll have to take another approach.

### 43 Responses»

• #1
• Comment
• Wed 14 Jan 2009
• 1704
##### Mark Richman wrote in to say...

Mathematica evaluates the initial equation as:

(3.07 F (1-(2.8 D^2 e)/V^2) Y)/D2

3.07

F

(

1

2.8

D
2

e

V
2

)

Y

D2

• #2
• Comment
• Wed 14 Jan 2009
• 1707
##### Phillip wrote in to say...

Someone sent me this link, and I just glanced at it. You’ll need to take the natural logarithm of e^whatever to bring down the exponents. ln(e^x) = x. That should help you along.

• #3
• Comment
• Wed 14 Jan 2009
• 1712
##### Mike Taylor wrote in to say...

mind = “blown”

but i did just forward this to my friend who’s finishing his phd in math.

• #4
• Comment
• Wed 14 Jan 2009
• 1720
##### Eric Meyer wrote in to say...

That was actually where I ran aground, Phillip, but in the sense that my attempts to do that failed to yield the correct results. As in, when I just took that part of the equation and started adding ln() to bits of it, then ran test data through it, I got different results than before I’d done so. Which means I was doing it wrong. I just don’t know how, exactly.

Not sure I understand the results you posted, Mark. Sorry!

• #5
• Comment
• Wed 14 Jan 2009
• 1721
##### Jason wrote in to say...

42

• #6
• Comment
• Wed 14 Jan 2009
• 1721
##### jrf wrote in to say...

Pff… been a very long time for me too….

Still breaking my head on the d/v bits, but hope this simplification helps a bit:

D = √ (3.07 × F × Y × (1 + 1.4 × (D / (V × e(2 × D/V))) / Q )

• #7
• Comment
• Wed 14 Jan 2009
• 1721
##### Mike D. wrote in to say...

I have no idea what the answer is, but I am shocked you are not using MathML to express this equation! Heresy! :)

• #8
• Comment
• Wed 14 Jan 2009
• 1723
##### Yann wrote in to say...

I’m afraid it can’t be done. To get that D out of the exponential function (e^x) you need logarithms and then the “1+” starts to bother.

How about an approximate iterative solution? :-)

• #9
• Comment
• Wed 14 Jan 2009
• 1727
##### mkjones wrote in to say...

Holy crap! What happened to the CSS stuff :-o

• #10
• Comment
• Wed 14 Jan 2009
• 1741
##### scragar wrote in to say...

I’m not sure if it’s possible, but the most important thing as I figure it would be to get rid of the exponient, that would be a good jumping place.

D^2 = 3.07FY(1 + 1.4(D/V)e^(2D/V))/Q
(Q D^2)/3.07FY = 1 + 1.4(D/V)e^(2D/V)
V(QDD/3.07FY – 1)/1.4V = e^(2D/V)
ln(V(QDD/3.07FY – 1)/1.4V) = 2D/V

At which point I think the whole thing starts to get even worse. If it wasn’t for that logarithm it would be possible to play around with it to get D on it’s own, but the logs and exponents mess everything up.

• #11
• Comment
• Wed 14 Jan 2009
• 1744
##### scragar wrote in to say...

OK, my above comment is messed up, I’ve lost a D on the third line and gained a V in it’s place.

• #12
• Comment
• Wed 14 Jan 2009
• 1744
##### Shane Witbeck wrote in to say...

Yann is correct. This cannot be rewritten in terms of D but you can use calculus to approximate.

• #13
• Comment
• Wed 14 Jan 2009
• 1746
##### akella wrote in to say...

CSS4? =)

I guess someone with Mathematica or Matlab will help…

• #14
• Comment
• Wed 14 Jan 2009
• 1747
##### Abraham Estrada wrote in to say...

You can’t get a single D because you have 3 Ds in your formula.

• #15
• Comment
• Wed 14 Jan 2009
• 1749
##### Phillip wrote in to say...

If you can rearrange D^(1/2 * 1/D) into an expression with only one D, I’ll give you the answer.

• #16
• Comment
• Wed 14 Jan 2009
• 1808
##### Jason Davis wrote in to say...

The equation is non-algebraic. Playing with the constants, you essentially are trying to solve an equation of the form:
x^2 = a(1 + b*x*e^x)
Where a = 4*3.07*F*Y/V^2, b = -0.7, and x = -2*D/V. You might be able to pull something out using the Lambert-W function, but really the best way to solve this is simply to compute values of a and b, then graph y=x^2-a(1+b*x*e^x) and find zeroes of the equation by graphical inspection. (Or do Newton’s method or a bisection algorithm…)

In any case, it’s not as simple as solving a quadratic equation or anything.

• #17
• Comment
• Wed 14 Jan 2009
• 1816
##### Kenneth wrote in to say...

The more advanced you get in physics, the more your complex equations start to disappear, since you are able to dismiss small terms, or you can ignore complex ones. This is the beauty of physics. :)

Alas, if you’re in for straight maths, I fear your answer will be found via numerical methods.

• #18
• Comment
• Wed 14 Jan 2009
• 1824
##### Daniel wrote in to say...

There is no closed form solution. The following easy recursion converges in all the cases you are interested in. With

c = 3.07/1.4 F Y V
d = -Q V / 1.4
f = exp(-2/V)

c+dD^2+ D f^D = 0

Rearrange it like this:

D = -c/(dD+f^D)

Now use this as a recurrence, that is, start with D=0, evaluate the right hand side, and plug the value into D, evaluate the right hand side, and so on. Keep on doing this until it converges, which will be quite soon.

• #19
• Comment
• Wed 14 Jan 2009
• 1825
##### Kevin wrote in to say...

This not a continuous function. It is not possible to solve in terms of D. Sorry.

• #20
• Comment
• Wed 14 Jan 2009
• 1828
##### Eric Wendelin wrote in to say...

Darn you, Eric! Now I have to stop all work to solve a hard problem!

• #21
• Comment
• Wed 14 Jan 2009
• 1902
##### Kyle Ridolfo wrote in to say...

42

• #22
• Comment
• Wed 14 Jan 2009
• 1904
##### Jason Davis wrote in to say...

@ Kevin: Being continuous has very little with being able to find an inverse, at least locally. Furthermore, the curve f(x) = x^2-a(1+b*x*e^x) clearly has a well-defined derivative, which is the heavy-handed way of proving that the curve is actually continuous.

• #23
• Comment
• Wed 14 Jan 2009
• 1904
##### Martin wrote in to say...

What on earth would you be doing that would require this equation? :)

• #24
• Comment
• Wed 14 Jan 2009
• 1916
##### Neal G wrote in to say...

Lol, Eric I think you got an entirely different crowd on this blog post.

• #25
• Comment
• Wed 14 Jan 2009
• 1917
##### Jason Davis wrote in to say...

One last insight:

Since x=-2*D*V (assuming D,V>0), e^x is fairly close to 0. So the solution will ultimately be dominated by x=-sqrt(a), which actually gives a tremendously good approximation for the solution (in the very least, an excellent initial value for the iteration:
x_0 = -sqrt(a)
x_{n+1} = -sqrt(a*(1 – 0.7 * x_n * e^(x_n)))
Daniel was correct (empirically at least) in that this seems to converge very rapidly.

• #26
• Comment
• Wed 14 Jan 2009
• 1921
##### Thomas Winsnes wrote in to say...

This doesn’t look too hard to me

lets do some substitution and make it look a lot nicer first ;)

x = (3.07 × F × Y × (1 + 1.4 × ((D/V) × e(-2 × D/V))))

Now we have this

Q = x / D^2

a lot nicer eh?

Multiply with D^2 on each side of the =

D^2 × Q = X

Divide by Q

D^2 = X / Q

Stick substutute the x back to what it was

D^2 = (3.07 × F × Y × (1 + 1.4 × ((D/V) × e^(-2 × D/V)))) / Q

D = Sqr( (3.07 × F × Y × (1 + 1.4 × ((D/V) × e^(-2 × D/V)))) / Q )

Not too complicated, and def nothing about logarithms

I’ll show you in an example with numbers too

80 / 2^2 = 20

80 / 4 = 20

80 / 20 = 4 = 2^2

Sqr( 80 / 20 ) = 2

test it on a calc, it works :)

• #27
• Comment
• Wed 14 Jan 2009
• 1924
##### Thomas Winsnes wrote in to say...

woha, hidden D’s I didn’t notice :S ignore my last post

• #28
• Comment
• Wed 14 Jan 2009
• 1934
##### Joël Kuiper wrote in to say...

That’s unfortunate. Mathematica says it’s not possible algebraically, but I could’ve messed up somewhere. Here’s the output:

As suggested above a numeric approach is best suited.

• #29
• Comment
• Wed 14 Jan 2009
• 2018
##### Thomas Winsnes wrote in to say...

This is as far as I got before I gave up

QV = (3.07FYV / D^2) + ((4.298FY / D) * (e^-2)^(D / V))

or if you prefer

Q = (3.07FY / D^2) + ((4.298FY / D^2) * (D / V) * (e^-2)^(D/V))

The exponentials are getting to me :(

• #30
• Comment
• Wed 14 Jan 2009
• 2103
##### Eric Meyer wrote in to say...

Well, dang. Looks like I’ll have to go with incrementing (or average-narrowing) D until I hit a reasonable approximation of the value of Q I’m seeking.

Incidentally, for those who are curious:

F = thermal partition (unitless)
Y = yield (KT)
V = visibility (miles)
D = distance (miles)

So it’s easy (relatively speaking) to calculate the radiant energy at a given distance. I had assumed that the inverse, finding the distance at which one find a given radiant energy, was a matter of reshuffling. Kind of frustrating to find that’s not so.

Thanks for all the effort and input, folks!

• #31
• Comment
• Wed 14 Jan 2009
• 2117
##### Kevin wrote in to say...

@ #22 (Jason Davis)

When D = 0, Q is undefined.
When D > 0, Q is positive.
When D < 0, Q is negative.

I don’t know where you got your equation, but the derivative of the equation at the top of the post is undefined at D = 0. Therefore, the function is not continuous.

The function may be solvable for only positive values of D, but I have no idea how to do that.

• #32
• Comment
• Wed 14 Jan 2009
• 2158
##### Daniel wrote in to say...

“Well, dang. Looks like I”ll have to go with incrementing (or average-narrowing) D until I hit a reasonable approximation of the value of Q I”m seeking.”

You can’t avoid iteration. But the recurrence I already suggested is way simpler than the bisection method. Here is the core of it:

c = 3.07/1.4*F*Y*V
d = -Q*V/1.4
f = math.exp(-2.0/V)
D = 0.0
for i in xrange(1000) :
D = -c/(d*D+f**D)

Or try Jason’s recurrence, it’s mostly the same.

• #33
• Comment
• Wed 14 Jan 2009
• 2232
##### Eric Meyer wrote in to say...

I believe you when you say yours and Jason’s approaches are simpler, Daniel. The only problem is that I don’t really understand what either of you are saying. Or, more precisely, how to actually go about doing what you’re telling me to do.

Like, at the end of your comment, you do a “for i in” operation with no actual i in the equation, which has the solve-for term D on both sides of the equation. At which point my brain shorts out. Sorry.

I think maybe all the brain cells that would normally go toward understanding that kind of thing are currently devoted to holding a functional copy of the CSS line layout model.

• #34
• Comment
• Thu 15 Jan 2009
• 0158
##### Yann wrote in to say...

When Jason says x_n he means <var>x<sub>n</sub></var> :-D

And Daniel’s i is just to express that repeating the assignation below 1000 times you’ll get an accurate enough solution

• #35
• Comment
• Thu 15 Jan 2009
• 0724
##### Jason Davis wrote in to say...

@Kevin:
Note that the domain of D is strictly positive; even including D=0 doesn’t introduce much difficulty. Glancing at the original function for Q, it definitely looks to be strict-monotonically decreasing, which should imply the existence of an inverse function over its range. (Existence doesn’t say anything about how to construct it, however.)

@Meyers:
Regarding the iteration, think of it as making a guess (x_0), then using that guess to make a *better* guess (e.g. going from x_n to x_{n+1}).

So:
var x0 = -Math.sqrt(a);
var x1 = -Math.sqrt(a*(1 – 0.7 * x0 * Math.exp(x0)));
while (Math.abs(x1-x0) > 1e-6) {
x0 = x1;
x1 = -Math.sqrt(a*(1 – 0.7 * x0 * Math.exp(x0)));
}

That would be some JS to quickly calculate my re-parameterized value of x. (Of course, x=-2*D/V, so you are actually interested in D=-x1*V/2.)

[Fished this version of the comment out of the spam filters and restored it. Sorry about that, Jason! -E.]

• #36
• Comment
• Thu 15 Jan 2009
• 0744
##### Eric Meyer wrote in to say...

I understood you up to the very last line about my actual interest, Jason. (And it’s “Meyer”– I paid extra to get have the trailing “s” removed, y’know.)

• #37
• Comment
• Thu 15 Jan 2009
• 0801
##### Philip (flip) Kromer wrote in to say...

You are exactly correct about both points, Eric. Here is what’s going on.

Daniel and Jason are both relying on a magic trick, the “iterative solution”: find an alchemy turning a good guess into a better guess. If you find such an alchemy and invoke it on a reasonable guess many, many times, you can find a result as close to the true answer as you have patience and bits.

Here is a working python function:
``` import math def distance_for_luminance(Q, F, Y, V): # set up some stuff c = 3.07 * F * Y / Q a = 1.04 / V f = math.exp(-2.0/V) # start with a terrible guess D = math.sqrt(a) # A whole bunch of times ("more than enough"), for i in xrange(10000): # Turn the good guess into a better guess D_new = (c / D) + a*c*(f**D) # And adopt the better guess as our new value D = D_new return D```

``` I think you'll have to reinsert indentation. Now, you may not believe in this magic trick, and why should you? (A mathematician can tell you why, and when, that's what Grad School is for, but never mind.) The beauty is that you don't have to trust the method: a true solution speaks for itself. ```

`Perhaps by iteration, or perhaps from a whisper by the goddess Namagiri into your ear as you slept, just plug all values into both sides and see how far off it is.`

• #38
• Comment
• Thu 15 Jan 2009
• 0804
##### Philip (flip) Kromer wrote in to say...

Hrm. Replace initial _ with spaces.
``` import math def distance_for_luminance(Q, F, Y, V): __# set up some stuff __c = 3.07 * F * Y / Q __a = 1.04 / V __f = math.exp(-2.0/V) __# start with a terrible guess __D = math.sqrt(a) __# A whole bunch of times ("more than enough"), __for i in xrange(10000): ____# Turn the good guess into a better guess ____D_new = (c / D) + a*c*(f**D) ____# And adopt the better guess as our new value ____D = D_new __return D ```

• #39
• Comment
• Thu 15 Jan 2009
• 0814
##### Yann wrote in to say...

Hi again, Erik (just kiddin’!)

Jason’s code iterates until two consecutive values of the sequence (x0 & x1) are close enough (10^-6 in his code) to be considered a solution X. But X=-2*D/V (see comment #25) so D=-X*V/2

• #40
• Comment
• Thu 15 Jan 2009
• 0840
##### Eric Meyer wrote in to say...

Oooo. Lights in my head (are those “headlights”?) are beginning to slowly come on. Thank you all!

• #41
• Comment
• Thu 15 Jan 2009
• 1434
##### AxsDeny wrote in to say...

My friend is a math professor. He says the following in response to me telling him that people are reporting that this isn’t possible:

People are, in this case, correct. Variables in a linear term and an exponential term are rarely solvable algebraically.

• #42
• Comment
• Fri 16 Jan 2009
• 0742
##### Stevie D wrote in to say...

As others have said, there is no way to rearrange that formula in terms of D. While you can use iterative and brute-force methods, Microsoft Excel can very easily do all the legwork for you! (Method below is for Excel 2000, commands might be different in newer versions!)

Put your known variables into Excel in cells A2:A5 (F,Y,D,V in that order – just because that’s the order they cropped up in the formula), you’ll have to make something up for D, then in A1 type the formula in:
=(3.07*A2*A3*(1+1.4*(A4/A5)*EXP(-2*A4/A5)))/(A4^2)

With A1 highlighted, go to Tools > Goal Seek. Set “to value” to what you want Q to be, and “by changing cell” to A4, and it will give you an approximation to about 3 or 4 dp.

• #43
• Comment
• Mon 9 Feb 2009
• 0704
##### eqd wrote in to say...

If 2 D/V is small (<<1) then Exp(-2 D/V) = 1-2 D/V (approximately) and the whole eqn. becomes quadratic in D hence can be easily solved.

Otherwise the it cannot be solved in terms of elementary
(high-school) functions.

Best regards.

Line and paragraph breaks automatic, e-mail address required but never displayed, HTML allowed: `<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> `

Remember to encode character entities if you're posting markup examples! Management reserves the right to edit or remove any comment—especially those that are abusive, irrelevant to the topic at hand, or made by anonymous posters—although honestly, most edits are a matter of fixing mangled markup. Thus the note about encoding your entities. If you're satisfied with what you've written, then go ahead...

January 2009
SMTWTFS
December February
123
45678910
11121314151617
18192021222324
25262728293031

• Posts: