Is it possible to represent pieces of two functions with one equation?

141 Views Asked by At

I'm trying to create a rudimentary weighting system for evaluating how close two numbers are to each other. (This corresponds to string lengths - coding project for work... happy to explain in more detail if you're curious.) The evaluation is simple... x/y. The problem is that when x > y, the number shoots up the graph exponentially. (Orange line in the graph below.) What I want, is when y > 1, the values should ramp back down, like the red line. I can easily put a conditional in my program to change the equation for y values greater than 1, but I'm hoping there is a more elegant solution. Is there a way to represent the two functions in the graph below for all values x where y<=1 in a single formula?

two exponential functions

1

There are 1 best solutions below

0
On BEST ANSWER

Many thanks, Travis. That was exactly what I was looking for.

enter image description here