How can I solve this problem?

SLSCoder

New member
Joined
Aug 24, 2021
Messages
11
I have a number, the 'high' that can be positive, negative or zero and can be a fraction.
I have another number, the 'low' that can also be positive, negative or zero and can be a fraction.
I have another number (a variable) that can be anywhere between the high and the low.

I need the high to be represented by 1 and the low to be represented by -1.
I need to find what the variable number would be (between 1 & -1).
 
I have a number, the 'high' that can be positive, negative or zero and can be a fraction.
I have another number, the 'low' that can also be positive, negative or zero and can be a fraction.
I have another number (a variable) that can be anywhere between the high and the low.

I need the high to be represented by 1 and the low to be represented by -1.
I need to find what the variable number would be (between 1 & -1).
Suppose I made a graph, and labeled two points on it: (H, 1) and (L, -1), where H and L are your given high and low values.

How would you write the equation of the line through those two points?

Do you see how this answers your question?
 
Suppose I made a graph, and labeled two points on it: (H, 1) and (L, -1), where H and L are your given high and low values.

How would you write the equation of the line through those two points?

Do you see how this answers your question?
Thanks for responding.
Sorry, I need this pretty badly but I don't know how to make the correlation between 'high' and 1 & 'low' and -1.
I can 'see' the graph in my head but I don't know what to do with it.

I don't know how to convert the graph to an equation (which is why I asked:)
(hi / 1) ?? (lo / -1) = var / x
Nope, I just don't know what to do with it.
I have to write software (code) that does this calculation.
 
Last edited:
Thanks for responding.
Sorry, I need this pretty badly but I don't know how to make the correlation between 'high' and 1 & 'low' and -1.
I can 'see' the graph in my head but I don't know what to do with it.

I don't know how to convert the graph to an equation (which is why I asked:)
(hi / 1) ?? (lo / -1) = var / x
Nope, I just don't know what to do with it.
I have to write software (code) that does this calculation.
I was hoping a coder would know some basic algebra when reminded of it.

We have points (H, 1) and (L, -1). The slope between those points is [imath]m=\frac{1-(-1)}{H-L} = \frac{2}{H-L}[/imath].

The point-slope form of a line is [imath]y=m(x-x_1)+y_1[/imath]. Plugging in [imath]m=\frac{2}{H-L},\ x_1=L,\ y_1=-1[/imath], we get the equation [imath]y=\frac{2(x-L)}{H-L}-1[/imath].

Can you take it from there?
 
Hi SLSCoder. Percents/Proportions is another way to think about that. This question involves four intervals, three of which are given. The first pair of intervals is defined by (Low to High) and by (Low to Middle). The second pair is defined by (-1 to 1) and by (-1 to x).

You desire the length (-1 to x) to be the same percentage of the length (-1 to 1) as the length (Low to Middle) is of the length (Low to High). In other words, you'd like to position variable x such that corresponding interval lengths are proportional to one another (also known as "drawing x to scale").

If you remember percents/proportions, that's another way to write and solve an equation for x.



Here are some hints, for anyone whose noggin needs a joggin'. To measure any (closed) interval on the Real number line, subtract the smaller endpoint (the left one) from the larger endpoint (the right one). For example, we write the length of the interval (-1 to x) as:

x - (-1)

That expression simplifies to what?

And here's an example of a proportion, written using ratios:

n/2 = 25/42

That example corresponds to "length n compares to length 2 the same way as length 25 compares to length 42" or equivalently "n is the same percentage of 2 as 25 is of 42".

Solving it yields n = 25/21 or 1.1905 (rounded).

Check it: Is 1.1905 the same percentage of 2 as 25 is of 42?

1.1905/2 = 0.595

25/42 = 0.595

n = 1.1905 checks. Each short length is 59.5% of its longer mate.



If any reader would like to try this approach, start by measuring the length of each interval (that is, express the four lengths using symbols L,M,H,x). Then set up and solve the proportion (that is, compare each short length to its longer mate, and set those ratios equal to one another). Solve for x, and you'll get a formula for x in terms of the known L,M,H.

?
 
I was hoping a coder would know some basic algebra when reminded of it.

We have points (H, 1) and (L, -1). The slope between those points is [imath]m=\frac{1-(-1)}{H-L} = \frac{2}{H-L}[/imath].

The point-slope form of a line is [imath]y=m(x-x_1)+y_1[/imath]. Plugging in [imath]m=\frac{2}{H-L},\ x_1=L,\ y_1=-1[/imath], we get the equation [imath]y=\frac{2(x-L)}{H-L}-1[/imath].

Can you take it from there?
Believe it or not I aced advanced college algebra about 35 years ago. That was the only math I ever had.
I started pre-algebra about a year before that but dropped out because my mom was dying.
I didn't use it at all for many years.
I was able to take college algebra without prerequisites because I had a BA degree (obviously not in math lol).

You are using things I don't understand like [imath], \frac and 'pluggin in'. Honestly I'd have to go back to college math for a couple years to understand this. What I got was this: -1 + 2 * (($var - $lo) / ($hi - $lo)); Thanks for your help:)[/imath]
 
You are using things I don't understand like [imath], \frac and 'pluggin in'. Honestly I'd have to go back to college math for a couple years to understand this. What I got was this: -1 + 2 * (($var - $lo) / ($hi - $lo)); Thanks for your help:)[/imath]
That's odd. You shouldn't be seeing the codes; the site translates them (called "LaTeX") into normal readable math. And you don't need to use them to use the site.

I suppose you are saying that you are using a language (unspecified) in which variable names are preceded by $, and if your input is $var, then the resulting number is -1 + 2 * (($var - $lo) / ($hi - $lo)). If so, then that's correct, though it could also be written as 2 * ($var - $lo) / ($hi - $lo) - 1.
 
Beer induced reaction follows.
I was hoping a coder would know some basic algebra when reminded of it.

We have points (H, 1) and (L, -1). The slope between those points is [imath]m=\frac{1-(-1)}{H-L} = \frac{2}{H-L}[/imath].

The point-slope form of a line is [imath]y=m(x-x_1)+y_1[/imath]. Plugging in [imath]m=\frac{2}{H-L},\ x_1=L,\ y_1=-1[/imath], we get the equation [imath]y=\frac{2(x-L)}{H-L}-1[/imath].

Can you take it from there?
Believe it or not I aced advanced college algebra about 35 years ago. That was the only math I ever had.
I started pre-algebra about a year before that but dropped out because my mom was dying.
I didn't use it at all for many years.
I was able to take college algebra without prerequisites because I had a BA degree (obviously not in math lol).

You are using things I don't understand like [imath], \frac and 'pluggin in'. Honestly I'd have to go back to college math for a couple years to understand this. What I got was this: -1 + 2 * (($var - $lo) / ($hi - $lo)); Thanks for your help:)[/imath]
I've seen this post in four math sites already.
Just in case you really aren't seeing Dr. P's latexified reply, here it is:
20210826_021513.jpg
 
Yea, I'm surprised any one person monitors all of those forums.
Dr. Peterson was a bit over my head as I mentioned in that thread.

I did get the answer:
-1 + 2 * ((x - lo) / (hi - lo));
A bit of testing and I'm pretty sure this is right.
If not please let me know.

Looking above I didn't see that last equation the last time I looked at that post.
It looks like a variation of the one I'm posting here (above).
I'll copy it and test it against the other one. I'm sure they're the same.
Thanks Dr. Peterson!

Thanks for responding.
 
I did get an answer to this from another forum:
-1 + 2 * ((X - lo) / (hi - lo));
 
I have to do this problem again, in reverse.
This time I have the number between -1 and 1.
I need the number between L and H.

Dr. Peterson you are correct about the $ (PHP) and it drives me up a wall.
I copied & pasted your post into Notepad++ (my IDE believe it or not) and your "LaTeX" got translated between copy & paste.

I think I've got it but I'd really like a math genius (Dr. Peterson?) to check my work.
Point1 = (1, H); Point2 = (-1, L); v is the given variable; y is what I'm after.
m = (H - L) / 1 - (-1)
m = (H - L) / 2
y = (H-L)(v+1)/2

I'll try it with numbers that would be likely for my app.
Point1 = (1, 10); Point2 = (-1, 1); v = -.3
m = y-y1/x-x1
m = 10-1/1-(-1)
y = (10 - 1)(-.3 + 1)/2
y = (9 * .7) / 2
y = 6.3 / 2 = 3.15 That looks pretty close to me.

The formula is: y = (H-L)(v+1)/2
Is that correct?
 
I have to do this problem again, in reverse.
This time I have the number between -1 and 1.
I need the number between L and H.

Dr. Peterson you are correct about the $ (PHP) and it drives me up a wall.
I copied & pasted your post into Notepad++ (my IDE believe it or not) and your "LaTeX" got translated between copy & paste.

I think I've got it but I'd really like a math genius (Dr. Peterson?) to check my work.
Point1 = (1, H); Point2 = (-1, L); v is the given variable; y is what I'm after.
m = (H - L) / 1 - (-1)
m = (H - L) / 2
y = (H-L)(v+1)/2

I'll try it with numbers that would be likely for my app.
Point1 = (1, 10); Point2 = (-1, 1); v = -.3
m = y-y1/x-x1
m = 10-1/1-(-1)
y = (10 - 1)(-.3 + 1)/2
y = (9 * .7) / 2
y = 6.3 / 2 = 3.15 That looks pretty close to me.

The formula is: y = (H-L)(v+1)/2
Is that correct?
Close; but you lost one piece.

We have y = 2*(x - lo) / (hi - lo) - 1. You want to solve for x. So we do a little algebra:

y = 2*(x - lo) / (hi - lo) - 1​
y + 1 = 2*(x - lo) / (hi - lo) ... added 1 to each side​
(hi - lo)(y + 1) = 2*(x - lo) ... multiplied each side by (hi - lo)​
(hi - lo)(y + 1)/2 = x - lo ... divided each side by 2​
(hi - lo)(y + 1)/2 + lo = x ... added lo to each side​

You are lacking the "+ lo".

Using your numbers (lo=1, hi=10, y=-0.3), I get

x = (hi - lo)(y + 1)/2 + lo = (10 - 1)(-0.3 + 1)/2 + 1 = 9(0.7)/2 + 1 = 3.15 + 1 = 4.15​

Here's the proof:

1631052613078.png
 
Top