I need to figure out how to fit an $x^3$ curve to fixed endpoints, but a variable middle

63 Views Asked by At

So a friend of mine has a little project going, and needs some help.

Basically, we want to create a function that takes two variables; One $X$, and one that we call $DC$ ("Difficulty Class, as this is for a pen-and-paper game).

The output should be $0$ if $X\leq (1/2)DC$, and it should be $100$ if $X\geq 2 DC$.

The rest of the curve should look roughly like an $X^3$ curve, centered around $DC$ (So it goes downwards below $DC$, and upwards over $DC$, with the derivative $F'(DC) = 0$ )

Thank you in advance!

2

There are 2 best solutions below

2
On BEST ANSWER

As stated, there is no unique solution. You are looking for a curve of the form $f(x)=ax^3+bx^2+cx+d$. You have three conditions to enforce:

$$ f(DC/2)=0\\ f(2DC) = 100\\ f'(DC)=0 $$

If you plug those conditions in the expression for $f$ (and its derivative) you will get a system of three equations in four unknowns ($a,b,c,d$). You need an additional condition to uniquely fix the solution. Perhaps you can fix $f(DC)$?

6
On

How about:

$y = \begin{cases} 0,&x\leq \frac{DC}{2}\\\frac{100}{1.5^3}\times(\frac{X}{DC}-\frac{1}{2})^3,&\frac{DC}{2}<X\leq 2\times DC\\ 100,&X>2\times DC \end{cases}$