Is it bug? CAS solve function. - 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: Is it bug? CAS solve function. ( /thread-10531.html) |

Is it bug? CAS solve function. - Lukia - 04-18-2018 04:16 AM
Hello I got new HP prime a month ago. I write 'solve ([a+5.6=6.6 -a+3b-1.2=-2.2], [a b])' in CAS mode. Answer is a=1, b=3.88578058619E-16. But, It is inaccurate. actually i think a=1, b=0. This happend same in Solve App. There is something I missed? about my prime Hardware Version C Software Version 2018 02 12 CAS 1.4.9 RE: Is it bug? CAS solve function. - Joe Horn - 04-18-2018 05:31 AM
If you want exact results from CAS, you must use exact inputs (no decimal points allowed). Try this version of your problem (obviously equivalent but using exact numbers) and you'll get the exact answers you expected. solve([a+56/10=66/10, -a+3b-12/10=-22/10], [a b]) RE: Is it bug? CAS solve function. - Tim Wessman - 04-18-2018 04:17 PM
Note that your numbers are correct as well! 0.000000000000000388578058619 is what it found.... which is basically 0 When solving using numerical methods, the computer changes the values by smaller and smaller amounts and attempts to converge onto a single number. However, it is very common that it can't "perfectly" find a number that works because computer numbers are not perfect! They have error built in, and algorithms can't be perfect in all situations. A human can look at a number and say "that should be 0" but that isn't always the case and a computer can't know it! Much of the work in making good math libraries is figuring out how to reduce or cancel as much of the error as possible. For example, what is 1/3 ? Well, if you are using exact, CAS type systems then it is the "concept of 1 divided by 3" or a "ratio of 1 over 3". You CANNOT numerically represent .333333....... as it repeats infinitely however. In this case, the generic "solve a number using a repetitive numerical calculation" algorithm in use can't perfectly converge down to 0. It does "almost" get there however. RE: Is it bug? CAS solve function. - Carsen - 04-18-2018 08:01 PM
You can also use the EXACT command to convert your equations from approximate to exact. Here I used within the solve command in the CAS environment (see one of the pictures below. The equation is outlined in red). You get the exact answers of 1 and 0 in this case. You can also use the Solve APP to get the answers (In two more pictures below). This solver only uses approximate answers so your 0 will just be a really small number. Extremely useful APP. RE: Is it bug? CAS solve function. - compsystems - 04-19-2018 03:55 PM
Why Xcas returns [[1,0]] if hp-prime & Xcas use the same math engine? solve([a+56/10=66/10, -a+3*b-12/10=-22/10],[a,b]) => [[1,0]] list2exp(solve([a+56/10=66/10, -a+3*b-12/10=-22/10],[a,b]),[a,b]) => a=1 and b=0 exp2list(ans(-1)) => [[1,0]] RE: Is it bug? CAS solve function. - Han - 04-19-2018 04:00 PM
(04-19-2018 03:55 PM)compsystems Wrote: Why Xcas returns [[1,0]] if hp-prime & Xcas use the same math engine? Joe already answered your question. If the user wants exact values, then exact inputs are needed (i.e. no decimals). RE: Is it bug? CAS solve function. - compsystems - 04-19-2018 04:22 PM
in the following example if you see two different results. HP-prime solve(x^3-1.1*x^2-65.4*x+229.5=0,x) {-9.,5.00000000001,5.09999999999} Xcas solve(x^3-1.1*x^2-65.4*x+229.5=0,x) list[-9.0,5.0,5.1] RE: Is it bug? CAS solve function. - Joe Horn - 04-19-2018 06:25 PM
(04-19-2018 04:22 PM)compsystems Wrote: in the following example if you see two different results. Prime's CAS uses a 48-bit binary mantissa for floating-point numbers. Hence: format(1.1,"d17") --> "1.099999999999994" format(65.4,"d17") --> "-65.39999999999963" format(229.5,"d17") --> "229.4999999999999" So it's no great surprise that inexact inputs result in inexact outputs. What does Xcas use for its internal representation of floating-point numbers? RE: Is it bug? CAS solve function. - parisse - 04-19-2018 07:08 PM
It's the same representation and you get the same answer (change the default value of Digits to 13 or 14 to see non rounded values). RE: Is it bug? CAS solve function. - Lukia - 04-21-2018 02:47 AM
All replies are helpful. Thank you. RE: Is it bug? CAS solve function. - compsystems - 04-21-2018 01:23 PM
in the configuration of the hp-prime only allows up to 12 digits, in the Xcas which is the highest number of digits? RE: Is it bug? CAS solve function. - DrD - 04-21-2018 02:58 PM
https://www-fourier.ujf-grenoble.fr/~parisse/giac/doc/en/cascmd_en/node28.html xcas: DIGITS:=1000; approx(pi); RE: Is it bug? CAS solve function. - compsystems - 04-21-2018 05:06 PM
but in the hpprime it only allows up to 12 digits on home view HDigits := 13 returns "HDigits(13) Error: Bad Argument Value" on cas view Digits := 1000; approx(π); returns 3.14159265359 Bug? Digits := 13; solve(x^3-1.1*x^2-65.4*x+229.5=0,x) returns {-9.,5.00000000001,5.09999999999} /!\ Digits command does not appear in the catalog RE: Is it bug? CAS solve function. - compsystems - 04-21-2018 05:26 PM
(04-21-2018 05:24 PM)moonbeam Wrote: With regards to floating point in CAS, see post #9 above.doesn't work Digits := 13; solve(x^3-1.1*x^2-65.4*x+229.5=0,x) returns {-9.,5.00000000001,5.09999999999} RE: Is it bug? CAS solve function. - Vtile - 04-21-2018 08:44 PM
(04-18-2018 04:17 PM)Tim Wessman Wrote: You CANNOT numerically represent .333333....... as it repeats infinitely however...If I'm not misunderstood (I'm not mathematician) this is true only in number bases like 2 or 10, but in base 3 (or other bases divisible by 3) it is exact. However in base 3 system the fractions like the 1/2 repeats infinitely. All of our common bases just happen to be the multiples of 2 and not 3. Nitpicking. PS. Hopefully my understanding is correct. RE: Is it bug? CAS solve function. - toml_12953 - 04-22-2018 03:00 AM
(04-21-2018 10:45 PM)moonbeam Wrote:(04-21-2018 08:44 PM)Vtile Wrote: PS. Hopefully my understanding is correct. I use either octal or hex so I'd like eight fingers on each hand! RE: Is it bug? CAS solve function. - Wes Loewer - 04-22-2018 04:03 PM
(04-22-2018 03:00 AM)toml_12953 Wrote: I use either octal or hex so I'd like eight fingers on each hand! As Tom Lehrer once said, "Base-8 is just like base-10 really --- if you're missing two fingers." https://www.youtube.com/watch?v=W6OaYPVueW4 |