osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

how to convert this psuedo code to python


On Fri, Sep 14, 2018 at 2:37 PM, Noel P. CUA <npcua at donbosco.edu.ph> wrote:
>  compose your own octave script to calculate the machine
> epsilon. Analyze the code.
>
> epsilon = 1
> DO
> IF (epsilon+1<=1) EXIT
> epsilon = epsilon/2
> END DO
> epsilon = 2 x epsilon
>

epsilon = 1

while epsilon + 1 > 1:
    epsilon = epsilon / 2.0

epsilon = 2 * epsilon


This will not work in Octave. But maybe it will help you in improving
your understanding of the solution.