linsolve sometimes returns incorrect answer - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: HP Prime (/forum-5.html) +--- Thread: linsolve sometimes returns incorrect answer (/thread-19036.html) |
linsolve sometimes returns incorrect answer - Wes Loewer - 10-27-2022 06:02 PM 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] RE: linsolve sometimes returns incorrect answer - Wes Loewer - 10-30-2022 02:43 PM Seems that this bug was introduced back in 2017. I can confirm the following: firmware 11226 (2016-12-08) does not have this bug firmware 11385 (2017-01-27) has this bug RE: linsolve sometimes returns incorrect answer - Albert Chan - 10-30-2022 03:57 PM We have the same bug for XCas 1.5.0-63 (win32), returning twice the correct answer. RE: linsolve sometimes returns incorrect answer - Wes Loewer - 10-30-2022 05:34 PM (10-30-2022 03:57 PM)Albert Chan Wrote: We have the same bug for XCas 1.5.0-63 (win32), returning twice the correct answer. Since xcas 1.9.0-7 does not have the bug anymore, perhaps it's already been fixed in the Prime CAS which we'll hopefully see it in the next firmware. RE: linsolve sometimes returns incorrect answer - Wes Loewer - 05-21-2023 11:22 AM (10-30-2022 05:34 PM)Wes Loewer Wrote:(10-30-2022 03:57 PM)Albert Chan Wrote: We have the same bug for XCas 1.5.0-63 (win32), returning twice the correct answer. I'm surprised that this bug which was fixed in xcas quite some time back is still present in the recently released Prime firmware. |