# Designing a symmetric function

I need to design an analytical function that looks like this (See figure bellow). The idea is to control the angles "a" at the beginning and at the end. If the function depends on x (any kind of parameter, angle, value in [-1,1], etc.), we should have f(x) symmetric to f(-x) towards the line y=-x+1 (orange line). I mean, I should be able to build in some ways with the symmetric function. For instance, we have x^2 symmetric to x^(1/2).

I can build this function with a Bezier curve, but I need an analytical form that would give something close to the Bezier solution.

Thanks :)

• what is the range for $x$, [-1,+1] as well? – mike Jun 14 '14 at 10:49
• x is in [0,1] for instance. – Vincent Garcia Jun 14 '14 at 12:13

A solution is a quadratic Bezier curve (a parabola), with control points $(0, 0)$, $(p, 1-p)$ and $(1, 1)$. The initial slope of this curve is $\frac{dy}{dx}=\frac{1-p}{p}=\tan(a+45°)$.

UPDATE: a more direct approach to the parabola.

Rotate the axis by $45°$ clockwise to make the axis of the parabola vertical. The equation is $v=\lambda u(\sqrt2-u)$, with the initial slope $\frac{dv}{du}=\lambda\sqrt2=\tan a$.

Then counter rotate using $u=\frac{x+y}{\sqrt2}$ and $v=\frac{y-x}{\sqrt2}$:

$$2(y-x)=\tan a(x+y)(2-x-y),$$

$$(\tan a)\ y^2\ +2(1-\tan a\ (1-x))\ y-(2x-\tan a\ x(2-x))=0.$$

• I already use a Bezier curve, but the problem is that my solution provides me a set of (x,y) values. If I want to know the function value for a specific x, I need to interpolate between the two pairs (x_i,y_i) and (x{i+1}, y_{i+1}) when x_i < x < x_{i+1}. – Vincent Garcia Jun 14 '14 at 11:07
• You can eliminate $t$ to get an implicit equation $f(x, y)=0$ - will be a conic -, andfrom ther an explicit relation $y=g(x)$ by solving the quadratic equation. – Yves Daoust Jun 14 '14 at 11:09
• Sounds great. I'll give it a shot. Many thanks ! – Vincent Garcia Jun 14 '14 at 11:13
• If I read you correctly, this means that for each $x$ value, I have to solve the equation to deduce $y$. Am I right? – Vincent Garcia Jun 14 '14 at 15:08
• Right (you can precompute the expression for the solution). As long as $a<45°$, only one root is relevant. Double check my solution for possible sign errors. – Yves Daoust Jun 14 '14 at 15:12

To simplify the solution, we assume that $0\le x\le 1$ and $0\le f(x)\le 1$. From your figure we obtain $f(0)=0$ and $f(1)=1$.

Now consider function $g(\xi)=f(\xi)-\xi$. We have $g(0)=g(1)=0$. It is represented by the red curve but viewed from a frame that the dotted line is the $\xi$-axis.

Setting $$g(\xi)=b+c \xi^2\text{ (1)}$$ and requiring that $$\frac{dg(\xi)}{d\xi}=\tan(a),\text{ } g(0)=0$$

We obtain: $$b=-\frac{\tan a}{2^{3/2}},\text{ }c=\frac{\tan a}{2^{1/2}}$$

Thus $f(x)=x+g(x)$ is probably the simplest curve that satisfies your criteria.

If you have other requirements, you may add higher order even terms in the expression (1).

• This solution does not have the orange axis of symmetry. – Yves Daoust Jun 14 '14 at 14:03