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])

edit retag close merge delete

Short answer: The program which does the solving (Maxima) explicitly does not take such assumptions into account when doing so, while it does for other algorithms like integration.

Sort by » oldest newest most voted solve returns a list of solutions. So you get something like solve([equ1,[equ2]],k,C).

You have to refer to an equation in the list:

solve([k^3==4*C,equC],k,C)

more

Thanks ndomes, yes it' an list or an array I should have find it on my own. sorry !

but why

Result=solve([k^3==4*C,equC],k,C)
show(Result)


does gives me [k=0,C=0] Surely it is not the good way to code ?

or maybe the assume() I put are not enough ?

I think I need to tell SageMath that k and C are the unknowns

In the end, to be clearer, how can I code so that when I have 2 equations like these:

   -3*C==k*p and k^3==4*C


SageMath gives me the answer for k=f(p) and C=f(p) ?

 -3*C==k*p
k==-3*C/p
k^3==4*C
k^3==(-3*C/p)^3 =4*C
k^3==C^2 * C * (-3/p)^3 ==4*C
C^2 * (-3/p)^3 ==4
C^2 ==4*(p/-3)^3
C   ==2*(p/-3)^(3/2)
####
k==-3*(2*(p/-3)^(3/2))/p


C == (-2 * p) * sqrt(-p) / (sqrt(3) * 3)

k == 2 * sqrt(-p) / sqrt(3)

WolframAlpha has no problem with these 2 equations

solve(-3*C==k*p  ,k^3==4*C,p<0) for C and k

C = -(2 sqrt(-p^3 ...
(more)

Finally I find a way to solve these two equations. ;-) surely not optimal, But at least it does!

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')
assume(C, 'real')
assume(k, 'real')
equC=-3*C==k*p
equD=k^3==4*C
ResultC=solve(equD,C)
for j in range(len(ResultC)) :
show(ResultC[j])
Rk=solve(equC.substitute(ResultC[j].lhs()==ResultC[j].rhs()),k)
del(Rk[len(Rk)-1])
show(Rk)
RC0=solve(equD.substitute(Rk.lhs()==Rk.rhs()),C)
#show(RC0)
RC=[RC0,solve(equD.substitute(Rk.lhs()==Rk.rhs()),C)]
show(RC)

more

Concerning (1), see casus irreductibilis in Wikipedia.

Life is hard...

more