Jan 26 2012 | 8:18 pm

Hi

brain not working

how can i achieve the following, preferably with expr

input: 1, output 0.1

input: 5, output 1.

input: 10, output 10.

I mean, this would do:

but it's a bit, erm what's the word, grokky?

Brendan

- Jan 26 2012 | 8:56 pmsee this post,not as straightforward, but same idea should get you there.* Hint you have 3 variables and 3 equations :)
- Jan 26 2012 | 9:32 pmAlso a bit kludgey, but:
- Jan 26 2012 | 9:43 pmHere you go
- Jan 26 2012 | 9:50 pmThanks chumsChris - split, of course!big_pause - I saw that thread too, but ran screaming from the equations, thanks for filling in the blanks - ps how the hell did you arrive at that function?? Give me your brain - NOW, mwah ha ha2 excellent solutions (3 if you count mine LOL)Brendan
- Jan 26 2012 | 10:38 pmit's pretty much the simplest functional form that fits the criteria.
- Jan 27 2012 | 12:37 ambig_pause: but how did you count the coefficients? That is indeed pretty awesome
- Jan 27 2012 | 6:24 amwhenever you have 3 points you can go with quadratic equation (the expression big_pause estimated) by that substitution algo from school (at least in germany).
- Jan 27 2012 | 6:35 amyea merkin math suxorz
- Jan 27 2012 | 10:54 amxidance pretty much has itgiven the choice of functiony = a + bx^candy = 0.1, x = 1y = 1, x = 5y = 10, x = 10gives us 3 equations0.1 = a + b*1^c = a + b => a = 0.1 - b [1]1 = a + b*5^c [2]10 = a + b*10^c [3]substituting [1] into [2] (you could sub into [3] here, doesn't matter)1 = 0.1 - b + b*5^c0.9 + b = b*5^ctake logs of both sides, to give an expression for c in terms of bln(0.9 + b) = ln(b*5^c)ln(0.9 + b) = ln(b) c*ln(5)c = (ln(0.9 + b) - ln(b)) / ln(5) [4]then, substituting [1] and [4] into [3], lets us find b10 = 0.1 - b + b*10^((ln(0.9 + b) - ln(b)) / ln(5))0 = -9.9 - b + b*10^((ln(0.9 + b) - ln(b)) / ln(5))at this stage I just ran through a quick hacked python script to find b (life's too short)once you have b, you can use [1] to get a, then either [2] or [3] to get c.yes, I'm a nerd.
- Jan 27 2012 | 11:43 ambp: this is awesome :)
- Jan 27 2012 | 8:09 pmso, I thought about this a little more. We can transform our linear inputs to this, and get the same problem as in the 'other' posthere's what we do. we have as our inputs (x's) that need mapping, [1, 5, 10].we shift this down to [0, 4, 9], then normalise to [0, 4/9, 1], or algorithmically[x1, x2, x3] -> [(x1-x1)/(x3-x1), (x2-x1)/(x3-x1), (x3-x1)/(x3-x1)] = [x1', x2', x3'] and these map = [y1, y2, y3]we now have a similar problem as in the post above, and can get the solution toy = a + b*x'^c : where x' = (x - x1)/(x3 - x1)for our new mappings (both for this case, and general algorithm)we have, for x1 = 1, x1' = 0, y = 0.1a = 0.1 or y1for x3 = 10, x3' = 1, y = 10y3 = 10 = a + b => b = 9.9 or y3 - y1and solving for x2 = 4, x2' = 4/91 = 0.1 + 9.9*(4/9)^c0.9/9.9 = (4/9)^cc = ln(0.9/9.9)/ln(4/9)ory2 = y1 + (y3 - y1)*x2'^cc = ln((y2 - y1)/(y3 - y1))/ln(x2')so for our specific case, we can writey = 0.1 + 9.9*x'^{ln(0.9/9.9)/ln(4/9)}y = 0.1 + 9.9*[(x - 1)/9]^{ln(0.9/9.9)/ln(4/9)}and for the general casey = y1 + (y3 - y1)*x'^{ln((y2 - y1)/(y3 - y1))/ln(x2')}with x' = (x - x1)/(x3 - x1) and x2' = (x2 - x1)/(x3 - x1)as before.and we can chuck this straight in an single expr - happy days
- Jan 27 2012 | 11:42 pmto find a ln or exp expression starting from 3 points - except when they are variables - youcould also just try manually which coefficient matches.
- Jan 27 2012 | 11:51 pm* waits for the punchline *
- Jan 28 2012 | 12:16 ampunch and judy are off