Topic: trying to create the inverse of a cubic equation

Dear Gurus, in the past every thing about graph that I used was just about perfect.

This is  the first time  that   I actually  have to use cubic equations generated by my input data points.

The matching equation graph  is very good.

I realised that  I need to have   the equation with Y as the  variable, meaning I needed the inverse function of a cubic equation.

But here my maths are too poor. However I thought that using my original  datapoints to create  the new equation should side step the problem.

But when I swap the same  x data with the y data....

The new cubic equation  to my surprise    has very poor  accuracy  .

I have pack the good cubic with graph and the bad cubic with graph in the  attached pdf

I would be most greatfull if someone can point out
a) this is not possible
b) I did this wrong

Bye and thanks
Fred

Post's attachments

Attachment icon e-mail IvanAccuracy inverse equation.pdf 195.68 kb, 689 downloads since 2012-08-30 

Re: trying to create the inverse of a cubic equation

You say Graph gives gives you the function f(x) = 1.2708e-6*x^3 - 5.0e-4*x^2 + 0.0482*x +14.0276, but that doesn't fit your points. Graph gives me the function f(x)=0.000127*x^3-0.046855*x^2+4.821215*x+1402.761999. Anyway I just want to point out that Graph interprets e in lower case as Euler's constant while E in capital is used for exponential notation.

But I think your real problem is that you assume the inverse of a third order polynomial is also a third order polynomial, and that is wrong.

If you have the generic function y=a*x^3+b*x^2+c*x+d the inverse is actually three functions:

x=(-(sqrt(3)*i)/2-1/2)*(sqrt(27*a^2*y^2+(-54*a^2*d+18*a*b*c-4*b^3)*y+27*a^2*d^2+(4*b^3-18*a*b*c)*d+4*a*c^3-b^2*c^2)/(6*sqrt(3)*a^2)-(a^2*(27*d-27*y)-9*a*b*c+2*b^3)/(54*a^3))^(1/3)-(((sqrt(3)*i)/2-1/2)*(3*a*c-b^2))/(9*a^2*(sqrt(27*a^2*y^2+(-54*a^2*d+18*a*b*c-4*b^3)*y+27*a^2*d^2+(4*b^3-18*a*b*c)*d+4*a*c^3-b^2*c^2)/(6*sqrt(3)*a^2)-(a^2*(27*d-27*y)-9*a*b*c+2*b^3)/(54*a^3))^(1/3))-b/(3*a)

x=((sqrt(3)*i)/2-1/2)*(sqrt(27*a^2*y^2+(-54*a^2*d+18*a*b*c-4*b^3)*y+27*a^2*d^2+(4*b^3-18*a*b*c)*d+4*a*c^3-b^2*c^2)/(6*sqrt(3)*a^2)-(a^2*(27*d-27*y)-9*a*b*c+2*b^3)/(54*a^3))^(1/3)-((-(sqrt(3)*i)/2-1/2)*(3*a*c-b^2))/(9*a^2*(sqrt(27*a^2*y^2+(-54*a^2*d+18*a*b*c-4*b^3)*y+27*a^2*d^2+(4*b^3-18*a*b*c)*d+4*a*c^3-b^2*c^2)/(6*sqrt(3)*a^2)-(a^2*(27*d-27*y)-9*a*b*c+2*b^3)/(54*a^3))^(1/3))-b/(3*a)

x=(sqrt(27*a^2*y^2+(-54*a^2*d+18*a*b*c-4*b^3)*y+27*a^2*d^2+(4*b^3-18*a*b*c)*d+4*a*c^3-b^2*c^2)/(6*sqrt(3)*a^2)-(a^2*(27*d-27*y)-9*a*b*c+2*b^3)/(54*a^3))^(1/3)-(3*a*c-b^2)/(9*a^2*(sqrt(27*a^2*y^2+(-54*a^2*d+18*a*b*c-4*b^3)*y+27*a^2*d^2+(4*b^3-18*a*b*c)*d+4*a*c^3-b^2*c^2)/(6*sqrt(3)*a^2)-(a^2*(27*d-27*y)-9*a*b*c+2*b^3)/(54*a^3))^(1/3))-b/(3*a)

Yes, this gets very complicated. It may be possible to simplify it, but I have not found out how.

I have attached a grf file that plots the functions. I use custom constants to specify a, b, c and d, so you can easily change the values for the original polynomial. Notice that Calculate with complex numbers in the Edit|Axes dialog must be checked.

Post's attachments

Attachment icon Fred.grf 2.69 kb, 466 downloads since 2012-09-01 

Re: trying to create the inverse of a cubic equation

Dear webmaster Ivan,
                       I am terribly sorry for making you spend so much time  on showing the inverse function. That was never my intention.
I was simply  asking "my maths being weak"  could I side step generating the inverse function by simply swapping the x and Y columns?

Before I enter into detail  I must apologize for indiscriminate mixing of e and E.

As I said above , I was just asking why a set of real points produce   a good fit third order equation.
But, If we interchange the data points columns making the y column become the x column and making  the x column become the y column. 
Then there is no  equation for a good fit...?
None of the 6 basic function type offer a good approximation to the data points.


X    Y     L<->R   X      Y        
0    1402          1402      0        
5    1426          1426      5        
10    1447          1447      10        
15    1465          1465      15        
20    1482          1482      20        
25    1496          1496      25        
30    1509          1509      30        
35    1519          1519      35        
40    1528          1528      40        
45    1536          1536      45        
50    1543          1543      50        
55    1548          1548      55        
60    1550          1550      60        
65    1553          1553      65        
70    1554          1554      70        
75    1555          1555      75        
80    1554          1554      80        
85    1552          1552      85        
90    1550          1550      90        
95    1547          1547      95        
100    1543          1543      100

So using these two sets of data points, now free from my E = e error   

As before ( two left hand data points  columns ) produce a very good fit cubic equation.
So good that my confidence level is very high to be able to  use the  cubic equation to get a good accuracy speed of sound at any temperature  in the 0 -  100ºC range.


I can also, using the two Right hand  data points columns,  get a curve which doubles back on itself.

As webmaster Ivan demonstrated in Fred.grf this curve can be synthesised using three  sub-curves joining at the appropriate coordinates.

Chapeau   Ivan.

From the programming point of view  my mind boggles or as you neatly summed  up....

"Yes, this gets very complicated. It may be possible to simplify it, but I have not found out how."

Well  after looking at  the available literature such as wikipedia where they list  attempts to solve from Babylonia 
through Arab times and up to  the renaissance Italians and Descartes, they had fun.
Today it looks as if for a simple program using the listed steps it is no-no.

Getting back to making the inverse function by swapping the x and  y columns, I just note the dots double back on
themselves offering two temperatures for a given speed

I personally  being of a cowardly nature (lazy? ) avoid this by  interpolating the temperature from two know points  of  speed value.   
Much quicker and  hugely less number crunching.

From all of the above   the answers to my two original questions are:-

a) this is not possible? ....... well yes but for the average mortal no !
b) I did this wrong ?  ........ yes definitely

So dear webmaster my humble apologies for  having put you to such creative effort and using so much time.

I will drop out of the thread.... but maybe a Pandoras box has been opened. Who knows?

Bye and many thanks
Fred
Madrid