Comments on: Mathematics Filter
http://ask.metafilter.com/351646/Mathematics-Filter/
Comments on Ask MetaFilter post Mathematics FilterFri, 22 Jan 2021 22:22:57 -0800Fri, 22 Jan 2021 22:38:37 -0800en-ushttp://blogs.law.harvard.edu/tech/rss60Question: Mathematics Filter
http://ask.metafilter.com/351646/Mathematics-Filter
Help a biologist trying to do math and in over their head.
I'm trying to do some modeling and would like to find the inverse of the equation f(x) = ln(|x|)/u - (ln(|vx-p|))/kv + C when 0<x<p/v.
Is this possible? Can anyone point me to a solution or a resource where people good at math answer these types of questions?
Stuck and really not sure who to ask. Thanks!post:ask.metafilter.com,2021:site.351646Fri, 22 Jan 2021 22:22:57 -080012%juicepulpMathNaturalLogEquationSolutionBy: Valancy Rachel
http://ask.metafilter.com/351646/Mathematics-Filter#5025802
Try wolfram alpha. It's a great site for evaluating math equations.comment:ask.metafilter.com,2021:site.351646-5025802Fri, 22 Jan 2021 22:38:37 -0800Valancy RachelBy: ktkt
http://ask.metafilter.com/351646/Mathematics-Filter#5025809
Wolfram Alpha is not loving this one, which is a bad sign for finding a closed form of the inverse in general.<br>
<br>
If u = kv, it looks like your inverse will be a logistic model, which I am guessing you already know. If u and kv are small integers (at most 4), you can potentially find a formula using the quadratic, cubic, or quartic formula. (The last two are pretty awful.) I am not spotting any other algebra that will work. (Caveat: I am a mathematician, but not one who routinely works with messy equations.)<br>
<br>
If a graph will suffice, Desmos can give you that (using sliders for your various constants).<br>
<a href="https://www.desmos.com/calculator/eos0blg5kq">https://www.desmos.com/calculator/eos0blg5kq</a><br>
<br>
<a href="https://math.stackexchange.com/">Math Stack Exchange</a> is probably where you would get the best answer, if one is possible.comment:ask.metafilter.com,2021:site.351646-5025809Fri, 22 Jan 2021 23:34:29 -0800ktktBy: aws17576
http://ask.metafilter.com/351646/Mathematics-Filter#5025810
What kind of answer do you need?<br>
<br>
For general values of the constants, the inverse function will not have a closed form (a nice formula in terms of familiar functions). But if you just need to compute values, there are lots of tools (<a href="https://www.desmos.com/calculator/rx6isqmjku">Desmos worksheet</a>, for example -- click the intersection of the curve and the line to get coordinates). Somewhere in between these poles is the possibility of a local approximation by series; would that be useful for your purposes?<br>
<br>
(On preview, my answer is very similar to ktkt's, right down to the Desmos worksheet -- and we picked remarkably similar values for the constants! I'm going to post anyway because I'm amused by the similarity...)comment:ask.metafilter.com,2021:site.351646-5025810Fri, 22 Jan 2021 23:39:09 -0800aws17576By: biogeo
http://ask.metafilter.com/351646/Mathematics-Filter#5025816
Fellow biologist here! I took a quick crack at it, and I might be having a brain fart but I think that while your equation probably is invertible in general, I'm not sure there's actually a simple algebraic form for the inverse. I can run you through the algebra I did to arrive at this conclusion, in case it helps you reason about your equation.<br>
<br>
Tackling this I would start by using a variable substitution x = p/v * z, so that 0 < z < 1, which makes some things easier to reason about. Also, for the sake of readability, I'd substitute s = 1/u and t = 1/kv. Then letting y = f(x),<br>
<br>
y = s*ln(|p/v * z|) - t*ln(|pz - p|) + C<br>
<br>
From your constraint, p/v and z are both positive, so we can just use the property of logarithms that ln(a*b) = ln(a) * ln(b), and write:<br>
<br>
y = s*(ln(p/v) + ln(z)) - t*(ln(|p|) + ln(|z-1|)) + C<br>
<br>
And since z < 1, ln(|z-1|) = ln(1-z). Then using the property of logarithms that a*ln(b) = ln(b^a), we can rewrite this as<br>
<br>
y = ln((p/v)^s) + ln(z^s) - ln(|p|^t) - ln((1-z)^t) + C<br>
<br>
There's a bunch of ugly terms there that are just constants, so we can introduce a new constant<br>
<br>
D = C + ln((p/v)^s) + ln(|p|^t)<br>
<br>
and we get<br>
<br>
y = ln(z^s) - ln((1-z)^t) + D<br>
<br>
And using the property of logarithms that ln(a) - ln(b) = ln(a/b),<br>
<br>
y = ln(z^s / (1-z)^t) + D<br>
<br>
Then we can start trying to solve for z (which will eventually let us get x). Subtracting D from both sides and taking the exponential, we get<br>
<br>
exp(y-D) = z^s / (1-z)^t<br>
<br>
And unfortunately I think that's it; I don't know of any tricks for dealing with the right-hand side here when s and t can be any arbitrary values. There might be some special cases for s and t (especially if they're integers) for which this has an algebraic solution, but in general I don't think you can separate things out any further than this. But you can at least graphically explore how changing the constants s and t affects your solution using your favorite plotting software. And if you have measured values for these constants, you can solve it numerically.<br>
<br>
On preview: I was going to also suggest Math Stack Exchange as another resource to check!comment:ask.metafilter.com,2021:site.351646-5025816Fri, 22 Jan 2021 23:51:33 -0800biogeoBy: Johnny Assay
http://ask.metafilter.com/351646/Mathematics-Filter#5025841
Physicist here; I deal with semi-nasty equations like this all the time. In principle, you might also be able to get a closed-form inverse function using biogeo's method, so long as the ratio between u and kv is a ratio of small integers (less than 5.) In that case, the problem reduces to finding the roots of a polynomial whose order is less than 5. But explicit solutions for cubic and quartic polynomials are (as noted above) extra nasty, and to be honest I doubt that it would elucidate any properties of the function.<br>
<br>
So the next steps really depend on what you want to do with this inverse function. If you just want a graph of it, <a href="https://www.desmos.com/calculator/5sdqjfasli">Desmos can do that</a>; just swap the roles of x and y when you enter the equation. If you want something else, post again and the boffins here might be able to help.<br>
<br>
<small>I unthinkingly tried to use MathJax several times in preparing this answer. That's what comes from hanging out on Physics & Math StackExchange.</small>comment:ask.metafilter.com,2021:site.351646-5025841Sat, 23 Jan 2021 06:19:37 -0800Johnny AssayBy: 12%juicepulp
http://ask.metafilter.com/351646/Mathematics-Filter#5025903
This is all brilliant, I'm blown away by how helpful everyone is. The Desmos graph feels a little bit like black magic and is definitely a huge step in the right direction! Finally a nice looking growth curve. <br>
<br>
This should allow me to verify that the equation fits the data. Assuming that checks out I want to see if I can derive the values of the different constants by by just measuring the initial growth rate and the time/rate when the growth rate is linear i.e. the inflection point for the growth curve. <br>
<br>
Doing this will definitely require some more math so if you want to play along check back later!comment:ask.metafilter.com,2021:site.351646-5025903Sat, 23 Jan 2021 11:11:48 -080012%juicepulpBy: SemiSalt
http://ask.metafilter.com/351646/Mathematics-Filter#5025928
We remember from calc 101 that the slope of the inverse is the inverse of the slope. 20 rabbits per day is equivalent to 1/20 of day per rabbit.comment:ask.metafilter.com,2021:site.351646-5025928Sat, 23 Jan 2021 12:40:09 -0800SemiSaltBy: a robot made out of meat
http://ask.metafilter.com/351646/Mathematics-Filter#5025991
It should be invertible, but probably doesn't have a clean analytic inverse. Just rearranging a bit, in this range exp(-y) = x^-1/u * (p/v-x) ^ (1/kv) * c is a product of two monotone decreasing functions, and exp is monotone. If this is a data analysis problem, you probably want to look into nonlinear least squares or mcmc analysis like stan.comment:ask.metafilter.com,2021:site.351646-5025991Sat, 23 Jan 2021 17:50:56 -0800a robot made out of meatBy: zengargoyle
http://ask.metafilter.com/351646/Mathematics-Filter#5026000
Pendantic (ha, hi biogeo): ln(a*b) = ln(a) * ln(b)<br>
I'm pretty sure that's : ln(a*b) = ln(a) + ln(b)<br>
I'm trusting that the actual equation stuff ln(|p/v * z|) can be turned into ln(p/v) + ln(z) ((dropping the |absolute| bit)) because both are positive.comment:ask.metafilter.com,2021:site.351646-5026000Sat, 23 Jan 2021 18:15:27 -0800zengargoyleBy: biogeo
http://ask.metafilter.com/351646/Mathematics-Filter#5026015
Whoops, thanks for the correction! Yeah, that was a typo. The logarithm of the product is equal to the sum of the logarithms. And yes, I dropped the absolute value where the argument was known to be positive.comment:ask.metafilter.com,2021:site.351646-5026015Sat, 23 Jan 2021 19:43:14 -0800biogeo