2
$\begingroup$

I have an $x$ value increasing from $340$ to $640$, and I want an $s$ value to move from $1$ to $0.5$ based on the $x$ value.

So I'm wondering, how can I achieve this?

I can get the first value in the range by dividing $340/340 = 1,$ but I don't know how to get to $0.5$ when $x$ is $640.$

$\endgroup$

2 Answers 2

3
$\begingroup$

Conditions:

$s(340) = 1$
$s(640) = 0.5$
linear (Actually affine)

To fit these conditions, first, take the starting points -- 340 and 640. As the difference is 300, an increase of 300 in x has to correspond to a decrease of 0.5 in s. Thus, the slope of the line will be $\frac{\Delta s}{\Delta x} = \frac{-0.5}{300} = -\frac{1}{600}$.

Now, taking the equation $s(x) = -\frac{x}{600} + b$ and solving for $b$ with the condition that $s(340) = 1$ gives that $1 = -\frac{340}{600} + b$, or $b = \frac{940}{600} = \frac{47}{30}$.

Thus, the resultant equation will be $s(x) = -\frac{x}{600} + \frac{47}{30}$. (Or, if you prefer to only have one fraction, $s(x) = \frac{940 - x}{600}$.)

Edit: It's also pretty easy to verify this afterwards. For example, $s(340) = \frac{940 - 340}{600} = \frac{600}{600} = 1$, and $s(640) = \frac{940 - 640}{600} = \frac{300}{600} = \frac{1}{2} = 0.5$.

$\endgroup$
1
  • $\begingroup$ I dont know how to thank you, its amazing @qaphla $\endgroup$
    – carbonr
    Commented Aug 13, 2013 at 19:01
0
$\begingroup$

\begin{align} \text{Assuming a linear relationship}\\ s&=mx+c\\ 1&=340m+c\\ 0.5&=640m+c\\ \text{Solving simultaneous equations,}\\ m&=-0.0017=\frac{1}{600}\\ c&=1.5667=\frac{940}{600} \end{align}

$\endgroup$
4
  • $\begingroup$ sorry, this didn't work as expected but nevertheless got the correct answer and thank you $\endgroup$
    – carbonr
    Commented Aug 13, 2013 at 19:05
  • $\begingroup$ what do you mean by "didn't work as expected"? $\endgroup$
    – Inquest
    Commented Aug 13, 2013 at 19:05
  • $\begingroup$ when i substitute m and c value in 340m+c I don't get 1 $\endgroup$
    – carbonr
    Commented Aug 13, 2013 at 19:46
  • 1
    $\begingroup$ @carbonr, it was -0.0017 instead of -0.017. $\endgroup$
    – Inquest
    Commented Aug 13, 2013 at 21:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .