Here is my problem. I don't have the privilege to upload a picture. I posted the same question in Stack Overflow here https://stackoverflow.com/questions/47333992/curve-fit-with-three-points-with-a-given-slope
For an easier visualization, I am going to describe an increasing function, but I need a solution for both directions.
Imagine a curve, cv1, with increasing Y value as X value increases. There are two additional points on the left-hand side of (and not on) the curve: pt1 on the X-axis in the negative direction and pt2 on the Y-axis in the positive direction. The third point, pt3, is basically the first point of cv1, that is, the left end point of it. The amplitude of pt1 is much larger than the X value of pt3; 30 to 100 times bigger.
I need a curve, cv2, that fits all three points, but with one more constraint:
- I want cv2 to have the same slope (tangent line) of cv1 at pt3 where they meet
It's OK for cv2 to have negative values past pt1, but at pt1, the Y-value has to be zero in that case. It's OK for pt3 not to be exactly on the X-axis (zero Y), but very close: asymptotic to X-axis. In that case, all Y values of cv2 will be positive.
I have tried different inverse functions such as exponential, high order polynomial, 1/something, etc., but without a slope constraint at pt3, the end-result tends to have a cusp at pt3 and it causes a problem for an overall analysis in which cv2 is used.
Can this be done?
The curve in your linked question looks a lot like an exponential. Let $(x_r,0)$ be the red point, $(0,y_b)$ be the blue point and $(x_g,y_g)$ be the green point. Let $s$ be the slope of the green curve at $x=x_g$.
Consider a fit candidate that's given by $f(x)$. We need to satisfy:
$$\left\{ \begin{array}{l} f(x_r)=0\\ f(0)=y_b\\ f(x_g)=y_g\\ f'(x_g)=s \end{array} \right.$$
That's four equations, so let's try something with four degrees of freedom, say $f(x)=a\cdot \exp(bx+c\cos(x))+d$. We have $f'(x)=a\cdot \exp(bx+c\cos(x))\cdot(b-c\sin(x))$, sothe system becomes
$$\left\{ \begin{array}{l} a\cdot \exp(bx_r+c\cos(x_r))+d=0\\ a\cdot e^c+d=y_b\\ a\cdot \exp(bx_g+c\cos(x_g))+d=y_g\\ a\cdot \exp(bx_g+c\cos(x_g))\cdot(b-c\sin(x_g))=s \end{array} \right.$$
Find a solution whichever way you like best and see if it looks like something that's good for you.