[Math] formula for asymptotic graph

algebra-precalculusasymptoticsgraphing-functions

I need help with an algorithm involving an asymptotic output.

I'm not a student and this is not homework, but it has been many years since I used to know how to figure this out. This will be used in creating a lookup chart for dice rolling in a RPG I am making. The input, $x$, is the difference between the character's stats (ie. attack skill vs enemy defense).

Acceptable values for $x$ will be positive integers
I want to calculate the output, $y$, to generate a graph whose curve is similar to this:
graph
but whose horizontal asymptote is $y=20$
and vertical asymptote at $x=0$.

I'm guessing there is an exponent somewhere in the formula but I can't figure how to generalize the formula structure. Like $y=x^2$ or whatever.

Best Answer

It would help to know more criteria since there are a lot of possible functions here. The hyperbola has been mentioned. Two more examples with some different behavior are $$y = 20 - 1000\frac{\exp(-\frac{x}{8})}{x}~ (in~ green~ below)\\ y = \frac{20x^{2}+x-10}{x(x+10)}~ (in~ black~ below)$$ The hyperbola solution is in red below. enter image description here

Basically $y = 20 - \frac{f(x)}{g(x)}$, up to tweaking signs of terms, will work if $g(0) = 0$ and $g$ has no other positive roots, and $\lim_{x\rightarrow +\infty} f(x) = 0$. Within reason you can get a lot of behaviors.

Edit: it appears the OP has some additional slope constraints. Basically every slope constraint requires a new coefficient. Consider the rational function $$R(x) = \frac{Ax^n + a_1x^{n-1} + \cdots - a_n}{x^n + x^{n-1} + \cdots + dx}, \forall i \in [1,n]~ (a_i \geq 0)$$ Only $a_n$ is marked as negative. Note this will match the criteria in the OP: $$\lim_{x\rightarrow +\infty}R(x) = A \\ \lim_{x\rightarrow 0^+}R(x) = -\infty$$ The derivative of $R(x)$ is relatively straightforward. Each variable we choose to be non-zero will allow us to specify a different slope at a different point; for instance, if we demand that $R'(1) = 1$ and we set $a_n=2$ then we can determine $d$ algebraically. If we instead demand only that $R'(1) \approx 1$ this gives us some more wiggle room to pick "nice" numbers. But in any case additional constraints require additional coefficients and as more conditions are added the exponent will start to rise in order to give us additional coefficients needed to fit our slope parameters.

But since we can always introduce more variables and higher exponents, we can always solve the system of equations demanded by all the required slopes.

Related Question