How to Map a Range to -1 to 1 in Relationships?

In summary, the conversation discusses mapping an interval between a high and low value to an interval between -1 and 1, with a variable in between. The suggested equation for this transformation is $\tilde{x} = -1 + 2\dfrac{x-low}{high - low}$, where $x$ is the original variable and $\tilde{x}$ is its new value. This equation can be written in code as -1 + 2 * ((X - lo) / (hi - lo)).
  • #1
SLSCoder
4
0
I have a number, the high, that could be positive, negative or zero and can be a fraction.
I have another number, the low, that could also be positive, negative or zero and can be a fraction.
I have another number, the variable that is between the high and the low.

It is safe to say that the high is greater than the low.
I need to represent the high as 1 and the low as -1.
Then I need to determine what the variable value would be (between 1 and -1).

How can I solve this?
 
Mathematics news on Phys.org
  • #2
\(\displaystyle \text{So you are mapping the interval $[low,~high]$ to the interval $[-1,1]$}\\
\text{Let $x$ be your variable that you want to transform, and $\tilde{x}$ be it's new value}\\
\text{It's assumed that $low \leq x \leq high$}\\~\\
\tilde{x} = -1 + 2\dfrac{x-low}{high - low},~ -1 \leq \tilde{x} \leq 1\)
 
  • #3
Thank you!
I need to write this function in code (software).
My math is pretty bad so I just want to clarify that the equation looks like this?

This is correct: low ≤ x ≤ high

-1 + 2 * ((X - lo) / (hi - lo));

I sure appreciate your help.
 
  • #4
looks good if your variables are now called hi and lo
 

FAQ: How to Map a Range to -1 to 1 in Relationships?

How can I communicate better with my partner?

Effective communication is key in any relationship. Start by actively listening and trying to understand your partner's perspective. Be honest and open about your feelings, and make sure to express them in a calm and respectful manner. It's also important to be a good listener and give your partner the space to express themselves.

What should I do if my partner and I have different values and beliefs?

It's common for partners to have different values and beliefs, and it's important to respect each other's perspectives. However, it's also important to have open and honest discussions about these differences and find ways to compromise and find common ground. Remember to focus on understanding each other rather than trying to change each other.

How can I rebuild trust in a relationship?

Rebuilding trust takes time and effort from both partners. It's important to acknowledge and take responsibility for any actions that may have caused the trust to be broken. Be consistent and follow through on your commitments, and be patient as trust is rebuilt. It's also important to communicate openly and honestly with your partner throughout the process.

How can I handle conflicts in a relationship?

Conflicts are a natural part of any relationship, and it's important to learn how to handle them in a healthy way. Start by taking a step back and identifying the root cause of the conflict. Communicate your feelings and needs calmly and listen to your partner's perspective. Remember to focus on finding a solution rather than winning the argument.

What should I do if I feel like my relationship is falling apart?

If you feel like your relationship is struggling, it's important to address the issues as soon as possible. Start by having an open and honest conversation with your partner about your concerns. Seek the help of a professional therapist or counselor if needed. Remember that both partners need to be committed to working on the relationship in order for it to be successful.

Similar threads

Replies
3
Views
1K
Replies
6
Views
4K
Replies
5
Views
874
Replies
8
Views
1K
Replies
5
Views
2K
Replies
1
Views
803
Replies
12
Views
4K
Replies
31
Views
2K
Back
Top