Post Reply 
little math puzzle. Map 1 0 -1 to 1 0.5 0
05-21-2018, 04:31 PM (This post was last modified: 05-21-2018 04:47 PM by Dieter.)
Post: #4
RE: little math puzzle. Map 1 0 -1 to 1 0.5 0
(05-21-2018 10:24 AM)pier4r Wrote:  One get in input a value that can be 1 or 0 or -1 .
The objective is to map those input to:
1 -> 1
0 -> 0.5
-1 -> 0

That's trivial since changing the input by 1 changes the output by 0,5. So (1|1), (0|0,5) and (–1|0) are points on a straight line with a slope of 0,5. Due to (0|0,5) the y-intercept is 0,5 as well. So you can get the parameters by simply looking at the data. ;-)

Instead of 0,5x + 0,5 you can also write (x+1)/2.
Or in RPN:

1
+
2
/

WP34s users can save a step with

INC X
#1/2
x


BTW, you may vary the puzzle with a non-linear mapping. For three points it can always be done with a parabolic fit. But maybe there also is another and shorter/faster way to do it. ;-)

What about

5 -> 2
2 -> 1
1 -> 0

As a kind of warm-up you may try

  1 -> 1
  0 -> 0
–1 -> 0

;-)

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: little math puzzle. Map 1 0 -1 to 1 0.5 0 - Dieter - 05-21-2018 04:31 PM



User(s) browsing this thread: 1 Guest(s)