locked
BigInteger log error bounds RRS feed

  • 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.name
    Tuesday, 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 framework-level 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:            rounds-FPU
    // - Int64               to        Single:            rounds-FPU
    // - BigInteger          to        Double:            rounds-FPU      TRUNCATES
    // - BigInteger          to        Single:            rounds-FPU
    // 
    // Fractional to fractional
    // - Decimal             to        Double:            rounds-FPU      FAILS
    // - Decimal             to        Single:            rounds-FPU
    // - Double              to        Decimal:           rounds-nte      FAILS(?)
    // - Single              to        Decimal:           rounds-nte      FAILS(?)
    // - Double              to        Single:            rounds-FPU
    // 
    // Fractional operations
    // - Log2(Double)        as        Double:            rounds-FPU      FAILS
    // - Log10(Double)       as        Double:            rounds-FPU      FAILS
    // - Log2(BigInteger)    as        Double:            rounds-FPU      FAILS
    // - Log10(BigInteger)   as        Double:            rounds-FPU      FAILS

    Anyway, I am not that expert in mathematical programming, so my tests (above all those marked as (?)) should be double-checked.

    -LV

    [Result table updated 2012-04-18.]


    Julio P. Di Egidio - Software Analyst Programmer - http://julio.diegidio.name


    Saturday, March 31, 2012 10:58 PM

All replies

  • It uses the Math library.  Same errors as any double calculation.
    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.name
    Wednesday, 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 framework-level 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:            rounds-FPU
    // - Int64               to        Single:            rounds-FPU
    // - BigInteger          to        Double:            rounds-FPU      TRUNCATES
    // - BigInteger          to        Single:            rounds-FPU
    // 
    // Fractional to fractional
    // - Decimal             to        Double:            rounds-FPU      FAILS
    // - Decimal             to        Single:            rounds-FPU
    // - Double              to        Decimal:           rounds-nte      FAILS(?)
    // - Single              to        Decimal:           rounds-nte      FAILS(?)
    // - Double              to        Single:            rounds-FPU
    // 
    // Fractional operations
    // - Log2(Double)        as        Double:            rounds-FPU      FAILS
    // - Log10(Double)       as        Double:            rounds-FPU      FAILS
    // - Log2(BigInteger)    as        Double:            rounds-FPU      FAILS
    // - Log10(BigInteger)   as        Double:            rounds-FPU      FAILS

    Anyway, I am not that expert in mathematical programming, so my tests (above all those marked as (?)) should be double-checked.

    -LV

    [Result table updated 2012-04-18.]


    Julio P. Di Egidio - Software Analyst Programmer - http://julio.diegidio.name


    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/nan-sys-fwk/

    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