# Math Help - I need someone to create a function with certain features

1. ## I need someone to create a function with certain features

I need a function f(x), that uses a as a constant.

-1<a<1

I need:
f(-1)=0
f(1)=1
f(a)=.5

The function must always have a positive (or zero) slope, and I would like it to be as smooth as possible.
I would also like the slope to be highest near a.

It must be continuous and differentiable everywhere from x=-1 to 1. Thanks

The function will be used in a computer program, so the most simple solution is best.

2. Very interesting problem, nathanf534! It took me a very long time to find even one solution. A simple cubic won't work, even if you use $y$ as the independent variable. Neither will a straight-forward arctangent function work. I'm assuming you need $x$ as the independent variable. My solution is a pasting of two functions together at $a$ such that the function values and the function derivatives match up there. Is that an acceptable solution? I also have a vertical tangent at $a$. I'm not sure if that's acceptable or not. Technically, the function is not differentiable there. I've tried making the solution better behaved there, but for some reason it's balking. Here is my solution so far:

$\displaystyle{f(x)=\begin{cases}
\end{cases}}.$

Let me know if this works for you. I obtained this solution through a rather circuitous route. First I solved the same problem, but with $x\in[0,1].$ The conditions turn out nicer and were easier to work with. I then transformed the solution into the proper domain by a linear transformation on $x$. The ansatz was two quadratics in $y$ that I pieced together at the required point, matching up both function values and derivatives. I also forced the concavities in order to assure that the derivative was maximized at $a$.

3. After further computations, I have discovered that, using this approach, the solution found above is the only solution. Now, a different ansatz may give better answers. However, this is what you get with this approach.

4. Thank you for taking time to solve this. I was hoping there was a more simple solution, but I will try out what you gave me and see what I can do with it.

5. There's another solution that my father produced. The only difficulty is that there is one parameter for which it is difficult to solve. Here is the solution:

$\displaystyle{y=\frac{\tan^{-1}\left(\frac{x-a}{b}\right)-\tan^{-1}\left(\frac{-1-a}{b}\right)}{\tan^{-1}\left(\frac{1-a}{b}\right)-\tan^{-1}\left(\frac{-1-a}{b}\right)}}.$

This satisfies $f(-1)=0,\;f(1)=1,$ monotone increasing, and the slope is maximized at $a$. However, you must solve for $b$ such that $f(a)=1/2.$ For all the cases I've tried, this is possible to do. However, I don't know how easy it would be to do numerically in whatever programming language you're using. You might try different methods, as well, depending on how many different $a$'s for which you must produce the curve.

If you simply write out the equation $f(a)=1/2,$ you obtain

$\displaystyle{\frac{-\tan^{-1}\left(\frac{-1-a}{b}\right)}{\tan^{-1}\left(\frac{1-a}{b}\right)-\tan^{-1}\left(\frac{-1-a}{b}\right)}=\frac{1}{2}}.$

It is possible to eliminate all the arctangents. However, the resulting algebraic equation is quite messy. If you can solve for $b$ numerically quickly enough for your application, I'd recommend that instead.