Cubic formula and vietes formulas

In summary: Comment=" "][Comment="-"][Comment="--"][Comment="---"][Comment="----"][Comment="-----"][Comment=" "][Comment="x1+x2+x3 and -b/a"][Comment="x1*x2+x1*x3+x2*x3 and c/a"][Comment="x1*x2*x3 and -d/a"]In summary, the conversation discusses a script that finds the roots of a cubic formula with complex coefficients. The script also checks the roots using Viete's formulas, but there seems to be an error with either the script or the formulas. The conversation includes a detailed explanation of the script and its functions.
  • #1
okkvlt
53
0
First, Is there a way to convert a complex number to polar form without using boolean commands?


And now, my real question:

Do all of viete's formulas hold true when the coefficients of a cubic formula are complex?

I wrote a script that finds the roots of a cubic formula with complex coefficients. At the end of the script i added some lines that check the roots using viete's formulas. But either somethings wrong with the script, or one of viete's formulas isn't true for polynomials with complex coefficients. I am guessing there's something wrong with the script.

x1+x2+x3 always equals -b/a, as it should
x1*x2+x1*x3+x2*x3 always equals c/a, as it should

but x1*x2*x3 does not equal -d/a, and i can't figure out why.

I looked over the script many times, and i can't find anything wrong with it. I'm sure the problem must be with the way i checked the roots, because the roots have to be correct for two of the formulae to work all the time. But i looked over the checking part of the script line by line and couldn't find anything wrong. The problem is that the values rproduct and rvieteproduct, and iproduct and ivieteproduct are not equal.

Maybe there's a real part of a complex number somewhere in the calculations that always equals zero and that screws up my polar form conversion. The problem with the program I am using is i can't use the equal sign in boolean conditions, only < and >. Can anybody think of a way to get around this?

Here's the script. It's fairly well organized. something like lzl is the magnitude of z, argz is the argument of z, rez or rz is the real part of z, imz or iz is the imaginary part of z. The coefficients are denoted by the letter of the coefficient(a,b,c,d) followed by r or i.

If you have the program "GraphCalc",(its freeware) you can run the script yourself to see what i mean.


#The Cubic Formula with complex coefficients
[Tab=output]

[PromptVal=ar:enter the real part of the coefficient of x^3]
[PromptVal=ai:enter the imaginary part of the coefficient of x^3]

[PromptVal=br:enter the real part of the coefficient of x^2]
[PromptVal=bi:enter the imaginary part of the coefficient of x^2]

[PromptVal=cr:enter the real part of the coefficient of x^1]
[PromptVal=ci:enter the imaginary part of the coefficient of x^1]

[PromptVal=dr:enter the real part of the coefficient of x^0]
[PromptVal=di:enter the imaginary part of the coefficient of x^0]


lal=(ar^2+ai^2)^.5

If(ar > 0)
arga=arctan(ai/ar)
EndIf
If(ar < 0)
arga=arctan(ai/ar)+pi
EndIf


lbl=(br^2+bi^2)^.5

If(br > 0)
argb=arctan(bi/br)
EndIf
If(br < 0)
argb=arctan(bi/br)+pi
EndIf


lcl=(cr^2+ci^2)^.5

If(cr > 0)
argc=arctan(ci/cr)
EndIf
If(cr < 0)
argc=arctan(ci/cr)+pi
EndIf


ldl=(dr^2+di^2)^.5
If(dr > 0)
argd=arctan(di/dr)
EndIf
If(dr < 0)
argd=arctan(di/dr)+pi
EndIf

ref=(lcl/lal)*cos(argc-arga)-(lbl^2/(3*lal^2))*cos(2*argb-2*arga)
imf=(lcl/lal)*sin(argc-arga)-(lbl^2/(3*lal^2))*sin(2*argb-2*arga)

reg=(2*lbl^3/(27*lal^3))*cos(3*argb-3*arga)+(ldl/lal)*cos(argd-arga)-((lcl*lbl)/(3*lal^2))*cos(argc+argb-2*arga)
img=(2*lbl^3/(27*lal^3))*sin(3*argb-3*arga)+(ldl/lal)*sin(argd-arga)-((lcl*lbl)/(3*lal^2))*sin(argc+argb-2*arga)

rep=lbl/(3*lal)*cos(argb-arga)
imp=lbl/(3*lal)*sin(argb-arga)

If(reg > 0)
argg=arctan(img/reg)
EndIf
If(reg < 0)
argg=arctan(img/reg)+pi
EndIf
lgl=(reg^2+img^2)^.5

If(ref > 0)
argf=arctan(imf/ref)
EndIf
If(ref < 0)
argf=arctan(imf/ref)+pi
EndIf
lfl=(ref^2+imf^2)^.5

req=27*lgl^2*cos(2*argg)+4lfl^3*cos(3*argf)
imq=27*lgl^2*sin(2*argg)+4lfl^3*sin(3*argf)

lql=(req^2+imq^2)^.5

If(req > 0)
argq=arctan(imq/req)
EndIf
If(req < 0)
argq=arctan(imq/req)+pi
EndIf

resquareroot=lql^.5*cos(argq/2)
imsquareroot=lql^.5*sin(argq/2)

reinside=reg/(-27^.5)+resquareroot
iminside=img/(-27^.5)+imsquareroot

linsidel=(reinside^2+iminside^2)^.5

If(reinside > 0)
arginside=arctan(iminside/reinside)
EndIf
If(reinside < 0)
arginside=arctan(iminside/reinside)+pi
EndIf


recuberoot1=linsidel^(1/3)*cos(arginside/3)
imcuberoot1=linsidel^(1/3)*sin(arginside/3)

lcuberootl=(recuberoot1^2+imcuberoot1^2)^.5

If(recuberoot1 > 0)
argcuberoot1=arctan(imcuberoot1/recuberoot1)
argcuberoot2=argcuberoot1+(2pi)/3
argcuberoot3=argcuberoot1+(4pi)/3
EndIf
If(recuberoot1 < 0)
argcuberoot1=arctan(imcuberoot/recuberoot)+pi
argcuberoot2=argcuberoot1-(2pi)/3+pi
argcuberoot3=argcuberoot1-(4pi)/3+pi
EndIf



recuberoot1=lcuberootl*cos(argcuberoot1)
imcuberoot1=lcuberootl*sin(argcuberoot1)

recuberoot2=lcuberootl*cos(argcuberoot2)
imcuberoot2=lcuberootl*sin(argcuberoot2)

recuberoot3=lcuberootl*cos(argcuberoot3)
imcuberoot3=lcuberootl*sin(argcuberoot3)


releft1=recuberoot1/2^(1/3)
imleft1=imcuberoot1/2^(1/3)

releft2=recuberoot2/2^(1/3)
imleft2=imcuberoot2/2^(1/3)

releft3=recuberoot3/2^(1/3)
imleft3=imcuberoot3/2^(1/3)

ltoprightl=lfl*2^(1/3)

reright1=(ltoprightl/lcuberootl)*cos(argf-argcuberoot1)
imright1=(ltoprightl/lcuberootl)*sin(argf-argcuberoot1)

reright2=(ltoprightl/lcuberootl)*cos(argf-argcuberoot2)
imright2=(ltoprightl/lcuberootl)*sin(argf-argcuberoot2)

reright3=(ltoprightl/lcuberootl)*cos(argf-argcuberoot3)
imright3=(ltoprightl/lcuberootl)*sin(argf-argcuberoot3)


[Comment=" "]
[Comment="-"]
[Comment="--"]
[Comment="---"]
[Comment="----"]
[Comment="-----"]
[Comment="x equals"]
rx1=(releft1-reright1)/3^.5-rep
ix1=(imleft1-imright1)/3^.5-imp
[Comment=" "]
[Comment="-"]
[Comment="--"]
[Comment="---"]
[Comment="----"]
[Comment="-----"]
[Comment="x equals"]
rx2=(releft2-reright2)/3^.5-rep
ix2=(imleft2-imright2)/3^.5-imp
[Comment=" "]
[Comment="-"]
[Comment="--"]
[Comment="---"]
[Comment="----"]
[Comment="-----"]
[Comment="x equals"]
rx3=(releft3-reright3)/3^.5-rep
ix3=(imleft3-imright3)/3^.5-imp
[Comment=" "]
[Comment="-"]
[Comment="--"]
[Comment="---"]
[Comment="----"]
[Comment="-----"]
[Comment="checking answers"]


rsum=rx1+rx2+rx3
isum=ix1+ix2+ix3
rvietesum=lbl/lal*cos(argb-arga+pi)
ivietesum=lbl/lal*sin(arga-argb+pi)

lx1l=(rx1^2+ix1^2)^.5
If(rx1 > 0)
argx1=arctan(ix1/rx1)
EndIf
If(rx1 < 0)
argx1=arctan(ix1/rx1)+pi
EndIf

lx2l=(rx2^2+ix2^2)^.5
If(rx2 > 0)
argx2=arctan(ix2/rx2)
EndIf
If(rx2 < 0)
argx2=arctan(ix2/rx2)+pi
EndIf

lx3l=(rx3^2+ix3^2)^.5
If(rx3 > 0)
argx3=arctan(ix3/rx3)
EndIf
If(rx3 < 0)
argx3=arctan(ix3/rx3)+pi
EndIf

rproductsum=lx1l*lx2l*cos(argx1+argx2)+lx1l*lx3l*cos(argx1+argx3)+lx2l*lx3l*cos(argx2+argx3)
iproductsum=lx1l*lx2l*sin(argx1+argx2)+lx1l*lx3l*sin(argx1+argx3)+lx2l*lx3l*sin(argx2+argx3)

rvieteproductsum=lcl/lal*cos(argc-arga)
ivieteproductsum=lcl/lal*sin(argc-arga)

rproduct=(lx1l*lx2l*lx3l)*cos(argx1+argx2+argx3)
iproduct=(lx1l*lx2l*lx3l)*sin(argx1+argx2+argx3)

rvieteproduct=(ldl/lal)*cos(argd-arga+pi)
ivieteproduct=(ldl/lal)*sin(argd-arga+pi)


[Comment="The following pairs of terms should be equal"]

[Comment="-----"]
rsum
rvietesum

[Comment="-----"]
isum
ivietesum

[Comment="-----"]
rproduct
rvieteproduct

[Comment="-----"]
iproduct
ivieteproduct

[Comment="-----"]
rproductsum
rvieteproductsum

[Comment="-----"]
iproductsum
ivieteproductsum
 
Mathematics news on Phys.org
  • #2
I'm not even going to try to read that! Polar form for a complex number, x+ iy, is either [itex]re^{i\theta}[/itex] or [itex]cos(\theta)+ i sin(\theta)[/itex]
where [itex]r= \sqrt{x^2+ y^2}[/itex] and [itex]\theta= arctan(y/x)[/itex]. I see no way of avoiding deciding whether or not x= 0 and if so whether y is positive or negative.

Yes, Vieta's formulas are true for complex coefficients as well as real coefficients.

Applying the cubic formula to complex coefficients you will have to be careful which cube and square roots you take. Remember that every complex number has two square roots and three] cube roots.
 

Related to Cubic formula and vietes formulas

1. What is the cubic formula?

The cubic formula, also known as Cardano's formula, is an algebraic formula used to solve cubic equations. It is a generalization of the quadratic formula and allows for the calculation of the roots of a cubic polynomial.

2. How is the cubic formula derived?

The cubic formula is derived using the method of substitution, where the cubic equation is transformed into a depressed cubic equation and solved using trigonometric functions. This method was first discovered by Italian mathematician Niccolò Fontana Tartaglia in the 16th century.

3. What are the limitations of the cubic formula?

The cubic formula can only be used to solve equations with real coefficients. It also involves complex numbers and multiple solutions, which can make it difficult to work with. Additionally, the formula can be quite lengthy and cumbersome, making it impractical for hand calculations.

4. What is Vieta's formula?

Vieta's formula, also known as Vieta's root theorem, is a mathematical relationship between the coefficients and roots of a polynomial equation. It states that the sum of the roots of a polynomial is equal to the negative of the coefficient of the second-highest power of the variable, divided by the coefficient of the highest power.

5. How is Vieta's formula applied in solving cubic equations?

Vieta's formula can be used to find the sum, product, and other relationships between the roots of a cubic equation. This information can then be used to simplify the equation and solve for the roots using other methods, such as the cubic formula or graphical methods.

Similar threads

Replies
2
Views
1K
  • Precalculus Mathematics Homework Help
Replies
14
Views
363
Replies
2
Views
3K
Replies
17
Views
3K
  • Calculus and Beyond Homework Help
Replies
1
Views
286
Replies
2
Views
5K
  • Differential Equations
Replies
7
Views
440
Replies
1
Views
5K
Replies
4
Views
467
  • Differential Equations
Replies
5
Views
1K
Back
Top