0
$\begingroup$

I'm normally a computer programmer but right now I'm trying to create a math formula for my computer program.

I have a variable i = 70, and another variable J = 15.

As J approaches 0, X should approach 100. I'm stumped what formula I should use.

It should be written something like this:

X = i + ( put operations that make x approach 100 as J approaches 0, J is inside these parenthesis )

And also, I can change 70 to a number between 0 to 100 and the operations above would still make x approach 100 as J approaches 0.

So with my example, if i is 70, when J = 7.5, X = 85 when J = 5, X = 90 when J = 2.5, X = 95

And so on... but i is a parameter that gets input by the user from 0 to 100

Please ask any other questions if I'm not explaining well enough.

$\endgroup$
2
  • $\begingroup$ Do you want it to approach linearly, quadratically, exponentially, etc... $\endgroup$ Sep 7, 2018 at 16:51
  • $\begingroup$ approach linearly $\endgroup$
    – ArmorCode
    Sep 7, 2018 at 16:54

2 Answers 2

2
$\begingroup$

Basically, you want your "line" of points of the form $(j,X)$ such that the points $(0,100)$ and $(15,i)$ are on the line.

So, your line will be $$X = \frac{i-100}{15}\cdot j + 100$$

$\endgroup$
0
1
$\begingroup$

In your example, you have the points (7.5,85), (5,90) and (2.5,95). Those can be written as (7.5, 100-7.5*2),(5,100-5*2),(100-2.5*2), so that suggests the formula X = 100-2J. More generally, a function that linearly approaches the point (0,100) will have the formula X = 100+mJ. If you want the function to also go through the point (15,i), then you can solve for m in terms of i: plugging in J = i and X = 15 gives you i = 100+15m, so m=(i-100)/15, giving you X=(i-100)J/15+100. You can also write it as X = 100-(100-i)J/15; this is a bit more transparent what's going on. Suppose X is height, and J is time. You start out at height 100, and as time goes on you go down from there. (Note that you've worded it as J starts at 15 and goes to 0, which makes things a bit confusing. I've worded it as starting at 0 and going to 15.)

final_J_value = 15 #your parameter i represents your height at time 15
initial_value = 100 #you start at 100
final_distance = initial_value-i #calculate how far away from the goal you are at the final time
speed = final_distance/final_J_value #the speed your height is decreasing is the total amount you decreased divided by how long it took to decrease that amount
current_distance = speed*J #your distance from the initial height is proportional to your speed and how long you have to go been going
X = initial_value-current_distance #current_distance is how far away X is from 100, so X is 100 minus that value
$\endgroup$
0

You must log in to answer this question.

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