# Gain function based on Bézier curves

I'm looking for a gain function, for range 0-1, where the output goes from 0-1 but at different pace.

Sure there are plenty of Log, Squares, sigmoids, tanhs but I was looking for something more flexible, and the I thought of the Bézier curves, for example:

where four parameters allow almost any curve.

Especially useful are the ones where the second set of parameters are symmetric, where it covers logit, square logit, symlog, and all the possible intermediary curves.

i.e.

The Béziers for 4 points are: $$P(t) = (1−t)^3P_1 + 3(1−t)^2tP_2 +3(1−t)t^2P_3 + t^3P_4 \\$$

So to make the gain function, I would need to express Y on base of Y, and as the point 1 in our case is (0,0), and point 4 is (1,1) and P2 and P3 will be our input parameters (as the cubic-bezier.com examples) . So I could write:

• X = Xa*3(1−t)^2*t + Xb*(1−t)*t^2 + t^3
• Y = Ya*3(1−t)^2*t + Yb*(1−t)*t^2 + t^3

Clear t in the first, substitute in the second, and we will have:

• f(x) = y = (¿Xa,Xb,Ya,Yb?)·x

But this goes beyond my capabilities :_((

Can anybody help me?

I want to implement this either on excel, python, or desmos:

PD: sorry, I think I asked in wrong forum, I hope the math.stackexchange.com is the right one, I am not sure if I should delete this one.

• Is this a Mathematica software question? In which case you have BezierFunction. Your wording is really confusing - do you want to express a Bézier curve in terms y = f(x) ? – flinty Apr 8 at 11:59
• Are you in the wrong forum? This one is focused on Wolfram's Mathematica software and language. – MarcoB Apr 8 at 12:00
• @flinty , yes, indeed I want to express a Beizer curve in terms of y = f(x), more precisely, f(x, Ox, Oy, Dx, Dy) beinf Ox,Oy,Dx,Dy the fous parameters correspoding the "other two points" /the second and the trhird, due to the first point is (0,1), and the second, obviously, (1,2) – vswers Apr 9 at 8:11
• and sorry for my wording, english not my languaje – vswers Apr 9 at 8:11

You can get Y[X] from:

eq = {X == Xa*3 (1 \[Minus] t)^2*t + Xb*(1 \[Minus] t)*t^2 + t^3,
Y == Ya*3 (1 \[Minus] t)^2*t + Yb*(1 \[Minus] t)*t^2 + t^3};
sol = Solve[Eliminate[eq, t], Y]


However, you get several possible very long solutions:

• how did you do that ??? I am impress – vswers Apr 9 at 8:07
• eqautions shouldnt be like : – vswers Apr 9 at 8:07
• eq = {X == Xa*3 + 3*(1 - t)^2*t + 3*Xb*(1 - t)*t^2 + t^3, Y == Ya*3 + 3*(1 - t)^2*t + 3*Yb*(1 - t)*t^2 + t^3}; sol = Solve[Eliminate[eq, t], Y] – vswers Apr 9 at 8:07
• Are you asking how I did it?. Well, you have 2 equations of 3 variables. Therefore, we may eliminate one, namely t. This leaves 1 equation of 2 variables, that can be solved for one of the variables, namely Y. – Daniel Huber Apr 9 at 8:45
• thanks, yes and no, I mean, I know the theory but I could don't do my self, and as soon as you use that syntaxis, I tought you use a software to solve it – vswers Apr 9 at 8:56