Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

about solve() 2 equations from degree 1

Hi I have 2 questions

1) Why, when I tell SageMath that k is a real number SageMath continues to give me complex solutions for k ?

2) why solve([k^3==4*C,equC],k,C) does not work ?

(when I uncomment the last line in the code below) I suppose the code is not correct ?.

t = var('t') # define a variable t
p = var('p') # constant cubic coeff 
q = var('q') # last constant cubic coeff
Delta = var('Delta') # cubic Discriminant  
theta = var('theta') # variable angle theta 
k = var('k') # real factor
C = var('C') # integer  multiplicatif factor
f = function('f')(t) # define f to be a function of t
Delta=-27*q^2 -4*p^3
assume(Delta>0) # 3 real roots
assume(C, 'real')
assume(k>0)
assume(k,'real')
equ=t^3 + p*t + q==0
trigequ=4*(cos(theta))^3 -3*cos(theta)==cos(3*theta)
equ1=equ.substitute(t=k*cos(theta))
equf=equ1.lhs()-q==C*trigequ.lhs()
show(equf)
#solve([equf],C,k)
equC=solve(3*C==k*p,C)
show(equC)
solve([k^3==4*C],k)
#solve([k^3==4*C,equC],k,C)

about solve() 2 equations from degree 1

Hi I have 2 questions

1) Why, when I tell SageMath that k is a real number SageMath continues to give me complex solutions for k ?

2) why solve([k^3==4*C,equC],k,C) does not work ?

(when I uncomment the last line in the code below) I suppose the code is not correct ?.

edited[june 27] because can't put new code in comment (I've been told is too long)

forget()
t = var('t') # define a variable t
p = var('p') # constant cubic coeff 
q = var('q') # last constant cubic coeff
Delta = var('Delta') # cubic Discriminant  
theta = var('theta') # variable angle theta 
k = var('k') # real factor
C = var('C') # integer  multiplicatif factor
f = function('f')(t) # define f to be a function of t
Delta=-27*q^2 -4*p^3
assume(Delta>0) # 3 real roots
assume(C, assume(p, 'real')
assume(k>0)
assume(k,'real')
assume(q, 'real')
equ=t^3 + p*t + q==0
trigequ=4*(cos(theta))^3 -3*cos(theta)==cos(3*theta)
equ1=equ.substitute(t=k*cos(theta))
equf=equ1.lhs()-q==C*trigequ.lhs()
show(equf)
#solve([equf],C,k)
equC=solve(3*C==k*p,C)
show(equC)
solve([k^3==4*C],k)
#solve([k^3==4*C,equC],k,C)
equC=-3*C==k*p
equD=k^3==4*C
show([equD,equC])
Result=solve([equD,equC],k,C)
for j in range(len(Result)) :
    show(Result[j])

about solve() 2 equations from degree 1

Hi I have 2 questions

1) Why, when I tell SageMath that k is a real number SageMath continues to give me complex solutions for k ?

2) why solve([k^3==4*C,equC],k,C) does not work ?

(when I uncomment the last line in the code below) I suppose the code is not correct ?.

edited[june 27] because can't put new code in comment (I've been told is too long)

forget()
t = var('t') # define a variable t
p = var('p') # constant cubic coeff 
q = var('q') # last constant cubic coeff
Delta = var('Delta') # cubic Discriminant  
theta = var('theta') # variable angle theta 
k = var('k') # real factor
C = var('C') # integer #real  multiplicatif factor
f = function('f')(t) # define f to be a function of t
Delta=-27*q^2 -4*p^3
assume(Delta>0) # 3 real roots
assume(p, 'real')
assume(q, 'real')
equ=t^3 + p*t + q==0
trigequ=4*(cos(theta))^3 -3*cos(theta)==cos(3*theta)
equ1=equ.substitute(t=k*cos(theta))
equf=equ1.lhs()-q==C*trigequ.lhs()
show(equf)
#solve([equf],C,k)
equC=-3*C==k*p
equD=k^3==4*C
show([equD,equC])
Result=solve([equD,equC],k,C)
for j in range(len(Result)) :
    show(Result[j])

about solve() 2 equations from degree 1

Hi I have 2 questions

1) Why, when I tell SageMath that k is a real number SageMath continues to give me complex solutions for k ?

2) why solve([k^3==4*C,equC],k,C) does not work ?

(when I uncomment the last line in the code below) I suppose the code is not correct ?.

edited[june 27] because can't put new code in comment (I've been told is too long)

forget()
t = var('t') # define a variable t
p = var('p') # constant cubic coeff 
q = var('q') # last constant cubic coeff
Delta = var('Delta') # cubic Discriminant  
theta = var('theta') # variable angle theta 
k = var('k') # real factor
C = var('C') #real  multiplicatif factor
f = function('f')(t) # define f to be a function of t
Delta=-27*q^2 -4*p^3
assume(Delta>0) # 3 real roots
assume(p, 'real')
assume(q, 'real')
equ=t^3 + p*t + q==0
trigequ=4*(cos(theta))^3 -3*cos(theta)==cos(3*theta)
equ1=equ.substitute(t=k*cos(theta))
equf=equ1.lhs()-q==C*trigequ.lhs()
show(equf)
#solve([equf],C,k)
equC=-3*C==k*p
equD=k^3==4*C
show([equD,equC])
Result=solve([equD,equC],k,C)
for j in range(len(Result)) :
    show(Result[j])