I'm trying to find a function $y=f(x)$ that can be described as follows:
$f(x) = g(x) + c/(x-x_a)$.
With $f(x)$ I want to design a function with the following properties:
- $f(0) = 0$;
- $f(x)$ has a maximum at $x_1, \quad x_1>0$;
- the maximum of $f(x)$ is $\max(f(x))=f(x_1)=y_\max$
- $f(x_2) = 0, \quad x_2>x_1$;
- $f(x)$ has a vertical asymptote at $x=x_a, \quad x_a<0$;
- $f(x)$ has a second asymptote which is a function $g(x)$;
Thus: I want to set $x_1, x_2$ and $y_\max$ and provide a function $g(x)$ to create a function with the listed requirements.
I have tried to implement this by solving a system of non-linear equations, but I could not achieve a function with all the listed conditions being met. I used MATLAB function fsolve to solve the unknown parameters of $g(x), c$ and $x_a$, by solving $f(x)$ for the unknown parameters manually (this could be done using the symbolic math toolbox as well).
An example, to give you a better feeling for what I'm looking for, is shown in the figure below. In the example, the asymptote function I used was $g(x) = ax+b$, so $a$ and $b$ are additional parameters to solve.

From the figure you can see that conditions $f(0)=0$ and $f(x_2)=0, x_2=7$ have been met, but in this case I didn't manage to set the desired value of the maximum ($y_\max$) at the desired $x$-value ($x_1$). How do I do this (by hand and/or using MATLAB)? Do I need to solve $\mathrm{d}f(x)/\mathrm{d}x=0$ for the parameters involving the peak height and $x$-location, or can this be done in a different or more efficient way?


OK, so my initial answer totally missed the point, but after having considered this a bit more, I came up with the following: $$ \begin{align} f(x)&=-\frac23x+\frac{50}9+\frac{-200/27}{x+4/3} \end{align} $$ which appears to solve the exact problem you posed. Here is a Wolfram|Alpha table confirming that $f(0)=f(7)=0$ and $f(2)=2$ as desired.
Here is how I found it:
The blue curve is given by $(x+k)^2(y+1)=(k+2)^2$ passing through $(2,0)$ and having asymptotes $x=-k$ and $y=-1$. The purple curve is given by $$ h(x)=-\frac{(k+2)^2}{x+k}-x $$ and is a primitive function of the blue curve $y=\dfrac{(k+2)^2}{(x+k)^2}-1$. Then writing out $h(0)=h(7)$ and solving for $k$ yields $k=4/3$. With this we are able to define the red curve, the solution to your problem, namely by scaling and transposing $h$ as follows: $$ f(x)=\frac{2}{h(2)-h(0)}\cdot(h(x)-h(0)) $$ in which $h(2)-h(0)=3$ and $h(0)=-25/3$, and the constants I wrote in the beginning of my answer follows as an immediate consequence of this after a couple of simple calculations.