Cubic formula and vietes formulas

Click For Summary
SUMMARY

The discussion centers on the application of Vieta's formulas to cubic equations with complex coefficients. The user developed a script to compute the roots of such cubic equations and verified the results against Vieta's formulas. While the sums of the roots and the sum of the products of the roots hold true, the product of the roots does not match the expected value, indicating a potential issue in the script. The consensus confirms that Vieta's formulas are valid for complex coefficients, but caution is advised when handling roots of complex numbers.

PREREQUISITES
  • Understanding of Vieta's formulas and their application in polynomial equations
  • Familiarity with complex numbers and their polar form representation
  • Proficiency in programming, specifically in scripting for mathematical computations
  • Knowledge of the cubic formula and its application to complex coefficients
NEXT STEPS
  • Explore the implementation of complex number polar form conversion without boolean commands
  • Investigate the nuances of Vieta's formulas in the context of complex coefficients
  • Learn about handling multiple roots in complex number calculations
  • Review debugging techniques for mathematical scripts to identify logical errors
USEFUL FOR

Mathematicians, software developers working with complex number computations, educators teaching polynomial equations, and anyone interested in the application of Vieta's formulas in complex analysis.

okkvlt
Messages
53
Reaction score
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
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.
 

Similar threads

  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 29 ·
Replies
29
Views
4K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 54 ·
2
Replies
54
Views
5K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 17 ·
Replies
17
Views
5K
  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 36 ·
2
Replies
36
Views
5K
  • · Replies 8 ·
Replies
8
Views
6K