Search code examples
octave

Octave-online.net vpa((pi-1),100) strange result?


in octave-online.net the vpa() function returns me the non precise result. If i try some computation with a lot digits behind decimal after 49's digit is the result zero. Is there some trick how to compute with a lot digits behind decimal?

vpa((pi-1),100)

returns:

2.141592653589793115997963468544185161590576171875000000000000000000000000000000000000000000000000000

I have similar problem for similar inputs with different length(e.g. vpa((113/111),100))

Thank You.

trying: vpa((pi-1),100)

expecting: 2.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117068


Solution

  • With vpa((p-1),100) the calculation of pi-1 is done using limited precision and the (imprecise) result is then applied to the vpa function.

    Instead, the vpa function needs to make the calculation:

       vpa('pi-1',100)
    

    giving the expected result:

    2.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117068
    

    See more details on the vpa reference page.