linsolve sometimes returns incorrect answer
|
10-27-2022, 06:02 PM
Post: #1
|
|||
|
|||
linsolve sometimes returns incorrect answer
I was solving a system of equations for physics and I came across what appears to be bug in the linsolve (and solve) function.
Code: linsolve([t1-m3*g=m3*a3, t2-m1*g=m1*a1, t2-m2*g=m2*a2, t1-2*t2=0, a1=-(a2+a3)/2], [t1,t2,a1,a2,a3]); xcas (and maxima) both give the results to be Code: [8*g*m1*m2*m3/(2*m1*m2+m1*m3+2*m2*m3),4*g*m1*m2*m3/(2*m1*m2+m1*m3+2*m2*m3),(-2*g*m1*m2-g*m1*m3+2*g*m2*m3)/(2*m1*m2+m1*m3+2*m2*m3),(-2*g*m1*m2+3*g*m1*m3-2*g*m2*m3)/(2*m1*m2+m1*m3+2*m2*m3),(6*g*m1*m2-g*m1*m3-2*g*m2*m3)/(2*m1*m2+m1*m3+2*m2*m3)] but the Prime CAS, HW 2.1.14603 (2021-12-02) and VC 2.1.14596 (2021-10-01), returns exactly twice the correct answers Code: [16*g*m1*m2*m3/(2*m1*m2+m1*m3+2*m2*m3),8*g*m1*m2*m3/(2*m1*m2+m1*m3+2*m2*m3),(-4*g*m1*m2-2*g*m1*m3+4*g*m2*m3)/(2*m1*m2+m1*m3+2*m2*m3),(-4*g*m1*m2+6*g*m1*m3-4*g*m2*m3)/(2*m1*m2+m1*m3+2*m2*m3),(12*g*m1*m2-2*g*m1*m3-4*g*m2*m3)/(2*m1*m2+m1*m3+2*m2*m3)] However, if I change the last equation from a1=-(a2+a3)/2 to the equivalent 2*a1=-(a2+a3), then the answers are correct. Also, if I plug in numeric values into the original equations, such as Code: linsolve([t1-30*10=30*a3, t2-10*10=10*a1, t2-20*10=20*a2, t1-2*t2=0, a1=-(a2+a3)/2], [t1,t2,a1,a2,a3]); Code: [4800/19,2400/19,50/19,-70/19,-30/19] |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
linsolve sometimes returns incorrect answer - Wes Loewer - 10-27-2022 06:02 PM
RE: linsolve sometimes returns incorrect answer - Wes Loewer - 10-30-2022, 02:43 PM
RE: linsolve sometimes returns incorrect answer - Albert Chan - 10-30-2022, 03:57 PM
RE: linsolve sometimes returns incorrect answer - Wes Loewer - 10-30-2022, 05:34 PM
RE: linsolve sometimes returns incorrect answer - Wes Loewer - 05-21-2023, 11:22 AM
|
User(s) browsing this thread: 1 Guest(s)