# Reduce occurrence of $x$, retain definition at $x=0$

I need to apply a gamma curve to render an output variable $(x)$, to make better use of screen real estate, and it has me scratching my head with what is probably a simple math question.

For $0 <= x <= 1$, this graph is the general form of my gamma curve, where $\gamma$ is a constant (approximately 7):

$$y = \frac{(\gamma + 1)x}{\gamma x + 1}$$

Note that $x$ appears twice. Evaluating $x$ has a significant load I'm trying to avoid applying twice, and language limitations prevent me from caching it without similar cost. I tried the following transformation, then realized it causes a division by zero error.

$$y= \frac{\gamma+1}{\gamma+\frac{1}{\displaystyle x}}$$

This leads me to the math question: Is it possible to keep $x=0$ in the problem domain without the $x$ term appearing more than once?

Please be gentle on me :)

EDIT: I swapped the order the equations were listed in, to address some comments. Also, if it is provably impossible to produce the same curve for $0<=x<=1$ with only one occurrence of the term $x$, then that's the answer I was looking for.

Your second equation is problematic too. You're multiplying by 0/0, which is undefined also, not 1. I wanted to point that out but don't yet have more help to offer. Maybe it will still help.

• Do you mean I've multiplied by $0/0$ in the process of transforming from the first to the second equation? If so, then I erred in which equation I listed first. Since my goal is to render this output with definition at $x=0$ the second equation is the correct one. – shannon Mar 6 '14 at 5:24
• Although, if it were also discontinuous at, say, any $x$ values $< 0$ or $> 1$ as a side effect of removing the second occurrence of the term, that would solve my functional requirement. – shannon Mar 6 '14 at 5:31
• Yes, I was saying you'd multiplied by 0/0 in transforming from the first to the second. In these cases it's common to define a value at x=0 explicitly. This makes your function piece-wise continuous to hide the discontinuity. It's not a hack so much as the actual functional behavior. – Daniel Black Mar 6 '14 at 5:31
• Unfortunately explicity defining a value at $x=0$ requires a test for $x=0$, thus incurring another evaluation/substitution of the term, which I'm trying to avoid. – shannon Mar 6 '14 at 5:34
• Apologies. You clearly stated that. I don't see a way around it, though, as it is discontinuous. – Daniel Black Mar 6 '14 at 5:39

If $x$ is not equal to $0$, then you can go from the first to the second equation. But, the last equation shows that there is a problem at $x=-1/\gamma$. If $\gamma >0$, no problem and you can use your second function for any $x>0$.

• $x >= 0$. If you are saying that with that in-mind I cannot transform from the first to the second equation, then it would be more correct to say the second equation is the more accurate (since my goal is to display a continuous "plot" of my $x >= 0$ input). So my question, though, is can I define the graph at $x=0$ without the $x$ term appearing twice? – shannon Mar 6 '14 at 5:15
• p.s. It may be possible for me to redefine my problem domain to $x > 0$, as you suggest. That's a small hack I was trying to avoid. – shannon Mar 6 '14 at 5:18
• As long as $x>0$, you do not have any problem. By the way, you changed your post after my answer. If you want no problem with continuity and no trouble with numerical overflows in the very immediate vicinity of $x=0$, just keep your first equation. By the way, remember that division is much more expensive than multiplication. – Claude Leibovici Mar 6 '14 at 5:58
• I did change my post, as I noted in my post, and it was specifically to clarify for you. However, you can also see in the edit history that see I described my need for definition at $x=0$ at the outset, even in the title. Thank you for the warning about the cost of division, but my truly costly operation is the evaluation of $x$, which requires aggregation over many rows of data, and cannot be cached without similar expense due to language limitations. – shannon Mar 6 '14 at 6:51