Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Having asked this question on the math overflow boards one of the contributors suggested this may be a more appropriate forum.

I have a cubic function in the form:

$$y = ax^3 + bx^2 + cx + d$$

...(where a, b, c and d are all known constants e.g -0.3, 3.5, 3.83 and 0 respectively) that produces a curve and allows me to calculate a point on that curve given it's x co-ordinate.

What I'd really appreciate help with is: How could I rewrite this equation to calculate the value of x if I knew the value of y?

I understand that cubic curves of this nature can have multiple (upto 3) values for x for any given y though I do not know how to calculate them, and my specific interest is only in the 'rightmost' x (i.e that with highest positive value).

Through research to date I gather my question relates some what to finding the roots of the cubic equation (where the given Y is specifically 0, so the values of x are where the curve crosses the horizontal axis) but I can't expand my admittedly hazy comprehension to calculating for different y values.

The only additional hint I've been able to glean is that because in my circumstances d is always 0 that I may not be dealing with a 'true' cubic function at all and instead might want to "factor out an 'x' and a quadratic".

I have noted there are similar questions posted here but these deal specifically with cubic bezier curves, where the form of the equation deals with t (time) based coefficients and the answers refer to expression of the curve in terms of control points rather then the a, b, c, d form.

Give me anything but mathematics to Google and I'm usually able to work something out for myself but in the sea of coefficients and polynomials I'm afraid I'm lost.

Thank you in adavnce for any pointers, John.

share|improve this question
1  
Check here en.wikipedia.org/wiki/Cubic_function –  DonAntonio Nov 24 '12 at 21:52
    
@John, To find the few digits of the roots of the polynomial for y=7 you can use the following command ? polroots(-0.3*x^3 + 3.5*x^2 + 3.83*x + 0 - 7) and it give the outputs %1 = [-1.8668678099915258022997098374482723451 + 0.E-38*I, 0.99697645750290058350037027443016802273 + 0.E-38*I, 12.536558019155291885466006229684770989 + 0.E-38*I]~ in pari/gp –  user50336 Nov 24 '12 at 22:58

2 Answers 2

up vote 0 down vote accepted

No John, modifying these formulas for y other than zero is pretty easy. You only change the value of $d$. If you want to solve $$−0.3x^3+0.5x^2+3.83x=0$$ you plug in $a=-0.3,b=0.5,c=3.83,d=0$. And then if you want to solve $$−0.3x^3+0.5x^2+3.83x=10$$ this is equivalent to $$−0.3x^3+0.5x^2+3.83x-10=0$$ so you plug in $a=-0.3,b=0.5,c=3.83,d=-10$ and get the $x$'s. So the general rule is if $$ax^3+bx^2+cx+d=f$$ then just substitute $a,b,c,d-f$ for $a,b,c,d$ in the formulas.

As for the complexity of the inverses, that is just the nature of polynomials. As the degree increases, the inverses get uglier and uglier. For degree five and above the general formulas don't even exist. Usually for the chicken in the oven type problem you are talking about, one can restrict the domain and hence the range (like the temperature can't be negative for example and the temperature will be monotonic in time, going up always) and then the inverse can become simpler.

share|improve this answer
    
Great answer Ali! Thank you, just the nudge I needed. For posterity, should anyone else need help with this, once you have the formula in the form Ali explains you need to 'factor out' to get the various possible values for x. Google "group factoring cubic equations" or just head over to this article on the [betterexplained] (betterexplained.com/articles/…) website. –  John Nov 24 '12 at 23:37

As your hint says, it is easy to solve your particular equation when $y=0$ as you have $$-0.3 x^3+0.5 x^2 + 3.83x =0$$ so either $x=0$ or $-0.3 x^2+0.5 x + 3.83 =0$ and you can solve the latter as a quadratic.

It is usually not so easy when $y \not = 0$ or in general for a cubic. Wikipedia gives the general (sometimes complex) form of the roots $$\begin{align} x_1 = &-\frac{b}{3 a}\\ &-\frac{1}{3 a} \sqrt[3]{\tfrac12\left[2 b^3-9 a b c+27 a^2 d+\sqrt{\left(2 b^3-9 a b c+27 a^2 d\right)^2-4 \left(b^2-3 a c\right)^3}\right]}\\ &-\frac{1}{3 a} \sqrt[3]{\tfrac12\left[2 b^3-9 a b c+27 a^2 d-\sqrt{\left(2 b^3-9 a b c+27 a^2 d\right)^2-4 \left(b^2-3 a c\right)^3}\right]}\\ x_2 = &-\frac{b}{3 a}\\ &+\frac{1+i \sqrt{3}}{6 a} \sqrt[3]{\tfrac12\left[2 b^3-9 a b c+27 a^2 d+\sqrt{\left(2 b^3-9 a b c+27 a^2 d\right)^2-4 \left(b^2-3 a c\right)^3}\right]}\\ &+\frac{1-i \sqrt{3}}{6 a} \sqrt[3]{\tfrac12\left[2 b^3-9 a b c+27 a^2 d-\sqrt{\left(2 b^3-9 a b c+27 a^2 d\right)^2-4 \left(b^2-3 a c\right)^3}\right]}\\ x_3 = &-\frac{b}{3 a}\\ &+\frac{1-i \sqrt{3}}{6 a} \sqrt[3]{\tfrac12\left[2 b^3-9 a b c+27 a^2 d+\sqrt{\left(2 b^3-9 a b c+27 a^2 d\right)^2-4 \left(b^2-3 a c\right)^3}\right]}\\ &+\frac{1+i \sqrt{3}}{6 a} \sqrt[3]{\tfrac12\left[2 b^3-9 a b c+27 a^2 d-\sqrt{\left(2 b^3-9 a b c+27 a^2 d\right)^2-4 \left(b^2-3 a c\right)^3}\right]} \end{align}$$

share|improve this answer
    
Thanks Henry. So the Wikiepedia reference you make, which I had looked at before posting, gives x1, x2 and x3 which are the x values of the three points on the curve where the curve crosses the horizontal axis, i.e. where y = 0 correct? If so, complex as they are, you're suggesting that modifying them so that they provide x(1, 2, & 3) when Y does not equal zero is a particularly non-trivial task? Are there any specific mathematicians who have solved the problem that I should be looking at? –  John Nov 24 '12 at 22:20
    
Additionally, is there a very simple concept I'm not grasping that explains why it's easy to work out the correlation of one axis to the other but not in reverse? Say I have the coefficients of a curve that specifies internal temperature of a chicken (y) against time spent in the oven (x). with the simple equation (y = ax3 + bx2 + cx) given any time I can easily tell you how hot my dinner is but given a target heat it seems disproportionately complex to calculate how long I'd have to be cooking to get there. –  John Nov 24 '12 at 22:26
    
@John: On your first comment, having $d$ zero and $y=k$ non-zero leads to the same solution for $x$ as having $d=-k$ and $y=0$. On you second question, it is usually easier to find a good numerical solution to a cubic by some form of approximation (you could start by sketching a graph). –  Henry Nov 25 '12 at 0:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.