Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Rightclick on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: SourceForge.net <noreply@so...>  20120724 06:22:14

Bugs item #3547315, was opened at 20120722 09:34 Message generated for change (Comment added) made by chrisrein You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=3547315&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  Floating point Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: christoph reineke (chrisrein) Assigned to: Nobody/Anonymous (nobody) Summary: Problems with bfloat Initial Comment: Enter: (%i2) fpprec:30; (%o2) 30 (%i3) bfloat((45.12*34.78923)^2); (%o3) 2.46392687692829128354787826538b6 2.46392687692829131776b6 is the correct value. build_info("5.27.0","20120508 11:27:57","i686pcmingw32","GNU Common Lisp (GCL)","GCL 2.6.8") Regards Chris  >Comment By: christoph reineke (chrisrein) Date: 20120723 23:22 Message: Thanks for your comment, but I’m still convinced that there is a bug somewhere. Please take a look at the following numbers: (%i1) bfloat(1.23456789123456789123456789123456789),fpprec:20; (%o1) 1.2345678912345678935b0 (%i2) bfloat(1.23456789123456789123456789123456789),fpprec:30; (%o2) 1.23456789123456789347699213977b0 (%i3) bfloat(1.23456789123456789123456789123456789),fpprec:40; (%o3) 1.23456789123456789347699213976738974452b0 (%i4) bfloat(1.23456789123456789123456789123456789),fpprec:50; (%o4) 1.2345678912345678934769921397673897445201873779297b0 The trouble begins after the second 9 with the sequence …3476…, which should be…1234… As you see, it doesn’t matter if fpprec=20,30,40 or 50, the precision is always the same! That ain’t got nothing to do with our binary system, fpprec doesn’t work properly. Maxima cannot handle long decimals (more than 17/18 places after the decimal point) and that’s a bug. The function fpprec seems to work if you have to compute real numbers like sqrt(2) or log(3). It never works if you enter long decimals.  Comment By: Raymond Toy (rtoy) Date: 20120723 09:04 Message: When you write 45.12, maxima converts that to a floating point number. But 45.12 cannot be represented exactly in floating point. Same for 34.78923. (You can see what the actual value is by using rationalize(45.12), which is close t o 4512/100, but not the same.) So maxima uses floatingpoint arithmetic to compute (45.12*34.78923)^2. Then that floating point number is converted to a bfloat, giving the result that maxima produces. If you want exact results, use exact rational arithmetic: bfloat((4512/100 * 3478923/100000)^2); 2.46392687692829131776b6 Of course, even that is an approximation because the exact result is 240617859075028449/97656250000, and that can't be represented exactly as a bfloat.  Comment By: christoph reineke (chrisrein) Date: 20120723 02:12 Message: Sorry, but I don’t understand you. <Can you explain why you think the value you give is the correct value?> Which value? (45.12*34.78923)^2=2.46392687692829131776b6=the correct value. Since I expect that the correct value has more than 16 digits after the comma, I use bfloat and fpprec=30. I quote from the documentation: “bfloat (expr) Function Converts all numbers and functions of numbers in expr to bigfloat numbers. The number of significant digits in the resulting bigfloats is specified by the global variable fpprec.” …all numbers…!! Now Maxima returns 30 digits, but the result is wrong. That’s all. <Thus, the simplifier has simplified the float expression…> Which simplifier? If a CAS computes a simple multiplication each digit of the displayed floating point number should be correct (apart from the last), no matter how many digits the user wants. Even if I erroneously “simplify” something, Maxima should never display a wrong result. That’s my opinion. How do I get the correct result? Thanks for your help!  Comment By: Raymond Toy (rtoy) Date: 20120722 13:07 Message: Can you explain why you think the value you give is the correct value? Consider this transcript: (%i1) fpprec:30; (%o1) 30 (%i2) trace(bfloat); (%o2) [bfloat] (%i3) bfloat((45.12*34.78923)^2); 1 Enter bfloat [2463926.876928291] 1 Exit bfloat 2.46392687692829128354787826538b6 (%o3) 2.46392687692829128354787826538b6 Thus, the simplifier has simplified the float expression before bfloat gets a chance to look at it.  You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=3547315&group_id=4933 