## [Maxima-bugs] [ maxima-Bugs-3558096 ] to_poly_solve gives a wrong solution for cos(x)=sin(3x)

 [Maxima-bugs] [ maxima-Bugs-3558096 ] to_poly_solve gives a wrong solution for cos(x)=sin(3x) From: SourceForge.net - 2012-09-01 22:24:26 ```Bugs item #3558096, was opened at 2012-08-15 17:46 Message generated for change (Comment added) made by jyoberle You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=3558096&group_id=4933 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Lisp Core - Solving equations Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Jean-Yves (jyoberle) Assigned to: Nobody/Anonymous (nobody) Summary: to_poly_solve gives a wrong solution for cos(x)=sin(3x) Initial Comment: Hi, When doing: load(to_poly_solve); algexact:true; to_poly_solve(cos(x)-sin(3*x),x); I get: to_poly_solve: to_poly_solver.mac is obsolete; I'm loading to_poly_solve.mac instead. %union([x=-(4*%pi*%z0+%pi)/4],[x=(4*%pi*%z1+%pi)/8]) But I think that the first solution should be (based on hand solving): (4*%pi*%z0+%pi)/4 (no minus sign). For example: if we consider %z0 = 0 in the to_poly_solve solution, we get x=-%pi/4 which is not a solution of the equation cos(x)-sin(3*x). On the other hand, if we set %z0 = 0 in the hand found solution, we get x=%pi/4 which is a solution. The build_info is: build_info("5.27.0","2012-05-08 11:27:57","i686-pc-mingw32","GNU Common Lisp (GCL)","GCL 2.6.8"). Best regards, Jean-Yves ---------------------------------------------------------------------- >Comment By: Jean-Yves (jyoberle) Date: 2012-09-01 15:24 Message: Aleksasd, I agree with you regarding your calculations. However, when I apply the function "trigsolve" to the equation, I get: trigsolve(cos(x)-sin(3*x),-%pi,%pi); {-(7*%pi)/8,-(3*%pi)/8,%pi/8,(5*%pi)/8} Several solutions are missing (e.g. %pi/4) because of the bug I highlighted. Best regards, Jean-Yves ---------------------------------------------------------------------- Comment By: Aleksas (aleksasd) Date: 2012-08-31 08:03 Message: To finding all solutions of trigonometric equation eq from interval [a, b] we define function "trigsolve": (%i1) trigsolve(eq,a,b):=block([s,i,ats,algebraic], algebraic:true, to_poly_solve([eq], [x],'simpfuncs = ['rootscontract,'expand,'radcan,'nicedummies]), s:makelist(rhs(part(%%,k)[1]),k,1,length(%%)), ats:[], for i:1 thru length(s) do (makelist(ev(s[i],%z0=k),k,-10,10), ats:append(ats,%%)), sublist(ats,lambda([e],e>=a and e<=b and float(ev(abs(lhs(eq)-rhs(eq)),x=e))

 [Maxima-bugs] [ maxima-Bugs-3558096 ] to_poly_solve gives a wrong solution for cos(x)=sin(3x) From: SourceForge.net - 2012-08-16 00:46:34 ```Bugs item #3558096, was opened at 2012-08-15 17:46 Message generated for change (Tracker Item Submitted) made by jyoberle You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=3558096&group_id=4933 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Lisp Core - Solving equations Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Jean-Yves (jyoberle) Assigned to: Nobody/Anonymous (nobody) Summary: to_poly_solve gives a wrong solution for cos(x)=sin(3x) Initial Comment: Hi, When doing: load(to_poly_solve); algexact:true; to_poly_solve(cos(x)-sin(3*x),x); I get: to_poly_solve: to_poly_solver.mac is obsolete; I'm loading to_poly_solve.mac instead. %union([x=-(4*%pi*%z0+%pi)/4],[x=(4*%pi*%z1+%pi)/8]) But I think that the first solution should be (based on hand solving): (4*%pi*%z0+%pi)/4 (no minus sign). For example: if we consider %z0 = 0 in the to_poly_solve solution, we get x=-%pi/4 which is not a solution of the equation cos(x)-sin(3*x). On the other hand, if we set %z0 = 0 in the hand found solution, we get x=%pi/4 which is a solution. The build_info is: build_info("5.27.0","2012-05-08 11:27:57","i686-pc-mingw32","GNU Common Lisp (GCL)","GCL 2.6.8"). Best regards, Jean-Yves ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=3558096&group_id=4933 ```
 [Maxima-bugs] [ maxima-Bugs-3558096 ] to_poly_solve gives a wrong solution for cos(x)=sin(3x) From: SourceForge.net - 2012-08-31 15:03:34 ```Bugs item #3558096, was opened at 2012-08-15 17:46 Message generated for change (Comment added) made by aleksasd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=3558096&group_id=4933 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Lisp Core - Solving equations Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Jean-Yves (jyoberle) Assigned to: Nobody/Anonymous (nobody) Summary: to_poly_solve gives a wrong solution for cos(x)=sin(3x) Initial Comment: Hi, When doing: load(to_poly_solve); algexact:true; to_poly_solve(cos(x)-sin(3*x),x); I get: to_poly_solve: to_poly_solver.mac is obsolete; I'm loading to_poly_solve.mac instead. %union([x=-(4*%pi*%z0+%pi)/4],[x=(4*%pi*%z1+%pi)/8]) But I think that the first solution should be (based on hand solving): (4*%pi*%z0+%pi)/4 (no minus sign). For example: if we consider %z0 = 0 in the to_poly_solve solution, we get x=-%pi/4 which is not a solution of the equation cos(x)-sin(3*x). On the other hand, if we set %z0 = 0 in the hand found solution, we get x=%pi/4 which is a solution. The build_info is: build_info("5.27.0","2012-05-08 11:27:57","i686-pc-mingw32","GNU Common Lisp (GCL)","GCL 2.6.8"). Best regards, Jean-Yves ---------------------------------------------------------------------- Comment By: Aleksas (aleksasd) Date: 2012-08-31 08:03 Message: To finding all solutions of trigonometric equation eq from interval [a, b] we define function "trigsolve": (%i1) trigsolve(eq,a,b):=block([s,i,ats,algebraic], algebraic:true, to_poly_solve([eq], [x],'simpfuncs = ['rootscontract,'expand,'radcan,'nicedummies]), s:makelist(rhs(part(%%,k)[1]),k,1,length(%%)), ats:[], for i:1 thru length(s) do (makelist(ev(s[i],%z0=k),k,-10,10), ats:append(ats,%%)), sublist(ats,lambda([e],e>=a and e<=b and float(ev(abs(lhs(eq)-rhs(eq)),x=e))
 [Maxima-bugs] [ maxima-Bugs-3558096 ] to_poly_solve gives a wrong solution for cos(x)=sin(3x) From: SourceForge.net - 2012-09-01 22:24:26 ```Bugs item #3558096, was opened at 2012-08-15 17:46 Message generated for change (Comment added) made by jyoberle You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=3558096&group_id=4933 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Lisp Core - Solving equations Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Jean-Yves (jyoberle) Assigned to: Nobody/Anonymous (nobody) Summary: to_poly_solve gives a wrong solution for cos(x)=sin(3x) Initial Comment: Hi, When doing: load(to_poly_solve); algexact:true; to_poly_solve(cos(x)-sin(3*x),x); I get: to_poly_solve: to_poly_solver.mac is obsolete; I'm loading to_poly_solve.mac instead. %union([x=-(4*%pi*%z0+%pi)/4],[x=(4*%pi*%z1+%pi)/8]) But I think that the first solution should be (based on hand solving): (4*%pi*%z0+%pi)/4 (no minus sign). For example: if we consider %z0 = 0 in the to_poly_solve solution, we get x=-%pi/4 which is not a solution of the equation cos(x)-sin(3*x). On the other hand, if we set %z0 = 0 in the hand found solution, we get x=%pi/4 which is a solution. The build_info is: build_info("5.27.0","2012-05-08 11:27:57","i686-pc-mingw32","GNU Common Lisp (GCL)","GCL 2.6.8"). Best regards, Jean-Yves ---------------------------------------------------------------------- >Comment By: Jean-Yves (jyoberle) Date: 2012-09-01 15:24 Message: Aleksasd, I agree with you regarding your calculations. However, when I apply the function "trigsolve" to the equation, I get: trigsolve(cos(x)-sin(3*x),-%pi,%pi); {-(7*%pi)/8,-(3*%pi)/8,%pi/8,(5*%pi)/8} Several solutions are missing (e.g. %pi/4) because of the bug I highlighted. Best regards, Jean-Yves ---------------------------------------------------------------------- Comment By: Aleksas (aleksasd) Date: 2012-08-31 08:03 Message: To finding all solutions of trigonometric equation eq from interval [a, b] we define function "trigsolve": (%i1) trigsolve(eq,a,b):=block([s,i,ats,algebraic], algebraic:true, to_poly_solve([eq], [x],'simpfuncs = ['rootscontract,'expand,'radcan,'nicedummies]), s:makelist(rhs(part(%%,k)[1]),k,1,length(%%)), ats:[], for i:1 thru length(s) do (makelist(ev(s[i],%z0=k),k,-10,10), ats:append(ats,%%)), sublist(ats,lambda([e],e>=a and e<=b and float(ev(abs(lhs(eq)-rhs(eq)),x=e))