0

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!

M47145
  • 4,106
TheJack38
  • 115

2 Answers2

1

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)$?

bartgol
  • 6,231
  • I can kinda fix f(DC)... I know for a fact that it can only take 5 forms; DC=20, DC=40, DC=60, DC=80, and DC=100

    So I'd have to make one equation for each of those 5 values of DC.

    – TheJack38 Apr 18 '16 at 22:14
  • Or you can fix one of the coefficients. For instance, you may take $a=1$, if you want your cubic function to grow roughly as fast as $x^3$... – bartgol Apr 19 '16 at 15:29
0

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}$

Doug M
  • 57,877
  • Unfortunately this will not work, as the middle formula is a linear formula, and I'm looking for a 3rd degree polynomial of sort. – TheJack38 Apr 18 '16 at 22:19
  • Sorry, moving to fast... is this better? – Doug M Apr 18 '16 at 22:27
  • Unfortunately not... The the DC assumes 5 values; 20, 40, 60, 80 and 100. X values will thus have similar ranges, and input that into the formula gives huge Y values, when Y is supposed to be between 0 and 100 – TheJack38 Apr 18 '16 at 23:09
  • one more edit, Is this working better for you. – Doug M Apr 19 '16 at 15:26
  • Unfortunately still not... Now it has the correct form, but the output only goes up to almost fifty when x=100, when it should be y=100.

    Thank you for the attempt though!

    – TheJack38 Apr 20 '16 at 08:26
  • if x = 100 and dc = 50. Then (100/1.5^3)(100/50 - 1/2) = 100. – Doug M Apr 20 '16 at 16:09