0

I'm trying to find the values a, b and c that would validate y = ax^2 + bx + c with the following parameters:

  • For x = 1; y = 1
  • For x = T; y = S

Essentially, I would like the function to pass through the (x, y) coordinates (1, 1) and (T, S) for any given S and T values.

This equates to:

a + b + c = 1
aT^2 + bT + c = S

Any help would be very welcome.

amd
  • 53,693
Pierre
  • 3
  • Another constraint is that all values should be positive. – Pierre May 30 '20 at 15:29
  • Note that the shape of your parabola is determined by $a,b$, when $c$ only performs a vertical translation of the curve. So you may want to fix $c$ and solve for $a,b$. Eventually check the minimum $c$ that makes $a,b>0$ afterwards. – zwim May 30 '20 at 15:37
  • What are "all values" that should be positive? Do you mean $a,b,c$ are all positive? If so, note that this puts a constraint on the possible values of $S$ and $T.$ For example, there would be no solution for $S=2,$ $T=1.$ – David K May 30 '20 at 17:44
  • I mean that for x ranging from 1 to T, the values of y should be positive and ranging from 1 to S. – Pierre May 30 '20 at 19:01
  • What I'm trying to achieve is to increase the size of a UI component quadratically, starting from a size of 1 at x = 1 and ending with the size of S at x = T. All size values (y values) should be positive. I know of S and T at runtime and need to define the values of a, b and c to fit the constraints defined above. – Pierre May 30 '20 at 19:06
  • So, are $T\gt1$ and $S\gt1$? – amd May 30 '20 at 22:04

1 Answers1

1

First of all, you must realise there is no unique solution for $a,b,c$, since two points don't define a unique quadratic parabola.

But you can find $b,c$ in terms of $a$.

Solve your equation system by subtracting one from the other:

$a(S^2-1) + b(S-1) = T-1$

$(S-1)[a(S+1) + b] = T-1$

$b = \frac{T-1}{S-1} - a(S+1)$

and $c = 1-a-b = 1-a+a(S+1) - \frac{T-1}{S-1} = aS - \frac{T-1}{S-1}+1$

So $a$ is a parameter you can vary, which determines the values of $b$ and $c$.

Note that you weren't clear about which values must all be positive. If it's supposed to be all of $a,b,c$, that very much depends on the values of $S$ and $T$. For example, when $S = 3, T=5$, if you choose a value of $a=1$, your $b$ will necessarily be negative. But for the same $S$ and $T$ values, a choice of $a=0.35$ gives positive values for $b\ \ (=0.6)$ and $c\ \ (=0.05)$

Some curve plots (for $a=1,a=2$ and $a=0.35$ with $S=3,T=5$): Plots

Deepak
  • 26,801
  • Thanks for your answer but I was in fact looking for a way to define a, b and c in terms of S and T rather than defining b and c in terms of a (since I don't know the value of a but do know the value of S and T). – Pierre May 30 '20 at 18:11
  • @Pierre But the point of this answer was that there are many choices for $a$, $b$, and $c$ in terms of $S$ and $T$: you have three unknowns and only two equations. If you use the parametrization Deepak gave you, you can vary $a$ until hopefully you find $b$, $c$ both positive. – rogerl May 30 '20 at 23:51