Answered by:
BigInteger log error bounds
Question

Hello guys,
Is anybody able to tell what are the error bounds for the logarithm with the System.Numerics.BigInteger?
Thanks in advance,
LV
Julio P. Di Egidio  Software Analyst Programmer  http://julio.diegidio.nameTuesday, November 16, 2010 7:46 PM
Answers

Unfortunately, it turns out the logarithm operations not only do not round correctly, in some cases they do not even return a result within 1 ULP of the correct result.
The outcome of my tests is as follows:
// Assert frameworklevel conversions: EXPECTED ACTUAL // // Fractional to integral: //  Decimal to Int64: truncates //  Decimal to BigInteger: truncates //  Double to Int64: truncates //  Double to BigInteger: truncates //  Single to Int64: truncates //  Single to BigInteger: truncates // // Integral to fractional //  Int64 to Double: roundsFPU //  Int64 to Single: roundsFPU //  BigInteger to Double: roundsFPU TRUNCATES //  BigInteger to Single: roundsFPU // // Fractional to fractional //  Decimal to Double: roundsFPU FAILS //  Decimal to Single: roundsFPU //  Double to Decimal: roundsnte FAILS(?) //  Single to Decimal: roundsnte FAILS(?) //  Double to Single: roundsFPU // // Fractional operations //  Log2(Double) as Double: roundsFPU FAILS //  Log10(Double) as Double: roundsFPU FAILS //  Log2(BigInteger) as Double: roundsFPU FAILS //  Log10(BigInteger) as Double: roundsFPU FAILS
Anyway, I am not that expert in mathematical programming, so my tests (above all those marked as (?)) should be doublechecked.
LV
[Result table updated 20120418.]
Julio P. Di Egidio  Software Analyst Programmer  http://julio.diegidio.name
 Marked as answer by Julio P. Di Egidio Saturday, April 14, 2012 10:43 PM
 Edited by Julio P. Di Egidio Wednesday, April 18, 2012 1:48 AM Updated results table.
Saturday, March 31, 2012 10:58 PM
All replies

It uses the Math library. Same errors as any double calculation.
 Marked as answer by Julio P. Di Egidio Wednesday, November 17, 2010 3:37 AM
 Unmarked as answer by Julio P. Di Egidio Saturday, April 14, 2012 10:43 PM
Tuesday, November 16, 2010 10:03 PM 
OK, makes sense: thanks for the reply.
LV
Julio P. Di Egidio  Software Analyst Programmer  http://julio.diegidio.nameWednesday, November 17, 2010 3:37 AM 
Unfortunately, it turns out the logarithm operations not only do not round correctly, in some cases they do not even return a result within 1 ULP of the correct result.
The outcome of my tests is as follows:
// Assert frameworklevel conversions: EXPECTED ACTUAL // // Fractional to integral: //  Decimal to Int64: truncates //  Decimal to BigInteger: truncates //  Double to Int64: truncates //  Double to BigInteger: truncates //  Single to Int64: truncates //  Single to BigInteger: truncates // // Integral to fractional //  Int64 to Double: roundsFPU //  Int64 to Single: roundsFPU //  BigInteger to Double: roundsFPU TRUNCATES //  BigInteger to Single: roundsFPU // // Fractional to fractional //  Decimal to Double: roundsFPU FAILS //  Decimal to Single: roundsFPU //  Double to Decimal: roundsnte FAILS(?) //  Single to Decimal: roundsnte FAILS(?) //  Double to Single: roundsFPU // // Fractional operations //  Log2(Double) as Double: roundsFPU FAILS //  Log10(Double) as Double: roundsFPU FAILS //  Log2(BigInteger) as Double: roundsFPU FAILS //  Log10(BigInteger) as Double: roundsFPU FAILS
Anyway, I am not that expert in mathematical programming, so my tests (above all those marked as (?)) should be doublechecked.
LV
[Result table updated 20120418.]
Julio P. Di Egidio  Software Analyst Programmer  http://julio.diegidio.name
 Marked as answer by Julio P. Di Egidio Saturday, April 14, 2012 10:43 PM
 Edited by Julio P. Di Egidio Wednesday, April 18, 2012 1:48 AM Updated results table.
Saturday, March 31, 2012 10:58 PM 
The source code for those tests is now available for download (under GPLv3) from: http://sourceforge.net/projects/nansysfwk/
I am unclear if there is point in reporting these issues to MS Connect: thoughts?
LV
Julio P. Di Egidio  Software Analyst Programmer  http://julio.diegidio.name
Wednesday, April 18, 2012 1:52 AM