From: Volker v. N. <vol...@gm...> - 2014-09-22 18:08:36
|
Am 22.09.2014 18:27, schrieb Raymond Toy: > > Volker> fpprec:30$ > Volker> x:0.5b0$ > Volker> asin(x); --> 5.23598775598298873077107230547b−1 > Volker> bs_asin(x); --> 5.23598775598298873077107230547b−1 > Volker> sin(asin(x)); --> 5.00000000000000000000000000001b−1 > Volker> bs_sin(bs_asin(x)); --> 5.00000000000000000023968760547b−1 > > Interesting. I'm sure this can be fixed, but it seems like an odd > artifact. > I fixed it. Now it seems that the bs_ functions are more accurate. fpprec:32$ x:0.5b0$ asin(x); 5.2359877559829887307710723054659b−1 wrong last digit bs_asin(x); 5.2359877559829887307710723054658b−1 OK sin(x); 4.7942553860420300027328793521557b−1 OK bs_sin(x); 4.7942553860420300027328793521557b−1 OK sin(asin(x)); 5.0000000000000000000000000000001b−1 bs_sin(bs_asin(x)); 5.0b−1 asin(sin(x)); 5.0000000000000000000000000000001b−1 bs_asin(bs_sin(x)); 5.0b−1 > > Volker> My functions have a bug where I need help. In case the return value is a > Volker> power of 2 and fpround has rounded from below I have the problem to fix > Volker> the exponent. It seems that I do not understand the mechanism of fpround > Volker> and *m in float.lisp. Can someone help? > > Can you give an example of the problem? I have not looked at fpround > in a very long time and don't really remember how it works anymore. > fpprec:30$ x:0.5b0$ asin(sin(x)); 5.0b−1 bs_asin(bs_sin(x)); 2.5b−1 BUG The essential lines of code: (defun bs-asincos (x fn) (let ((phi (let* ((fpprec (+ fpprec 12)) I leave out some lines here. phi is now computed with 12 extra bits and the following line is the correct result but with 12 bits extra. (print (bs-carg1 re-z im-z fpprec)) ))) After returning from the block of higher precision I want to round back to the original precision: (list (print (fpround (car phi))) (print (cadr phi))) )) ; BUG print 1 : (20769187434139310514121985316880257 -1) OK print 2 : 2535301200456458802993406410752 OK print 3 : -1 WRONG The exponent must be 0 instead of -1. The binary output shows the reason. fpround rounds from below. print 1 : (111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110000001 -1) print 2 : 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 print 3 : -1 How do I get noticed when to change the exponent? How can *m help here? Thanks in advance Volker > Ray > > > ------------------------------------------------------------------------------ > Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer > Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports > Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper > Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer > http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk > _______________________________________________ > Maxima-discuss mailing list > Max...@li... > https://lists.sourceforge.net/lists/listinfo/maxima-discuss > |