From e1f9d06b359d79c4d75a1ad7a1fcec29cb138985 Mon Sep 17 00:00:00 2001 From: schrom01 Date: Mon, 10 Oct 2022 18:44:51 +0200 Subject: [PATCH] Solved Task 4 --- HM1_Serie2.pdf | Bin 136870 -> 136870 bytes Schenk_Brandenberger_S2_Aufg4.py | 46 +++++++++++++++++++++++++------ 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/HM1_Serie2.pdf b/HM1_Serie2.pdf index aeded75a9ecb56e80978e1ae96f019d5f43fff0a..d1f9eb88cd53bf046e298260a5390f2067c8d5ca 100644 GIT binary patch delta 4305 zcmV;?5H9bgtq7*A2(TFg3O7_SF*-6iIx#YXBLlZ10|Dj#e;y|s6^%2VZZFS1o~|+F z@#Ya`HCJbE@pDJ5j9ihzh!@-L>S}$~v?ty9^%^r?Jbbx2`FMW*rn|V{i7(!7t{eQ9 z0o=&|8naR>+5G*R9?;*v{Z{6GgyzTVvrV_q z{K`zJbk|2HLu#I4^Eo)#ro6k^$oarD7~BT#6IjzI3L23mFWV`HEz&fy0k-2 z>2MT2_qywK!m0iF$={ydd-&b`#}8jZkF+P7?e*^d`);+Z+3|nm?KnS44x|5zirNT@2{cx%ciDl-~IXLU;gqF)_&&em5tt8+Njym z(56SNOv@|ZzyJ8rkN0`yDbi*iYoqtDK5}idy!MYzp8fLZ3D$o6!vyW<_t&=bwP6~M zTH7tJ{p8unqq|Sj+Ec{I?l11YcJZ*h_`SQ|e?NT5toHmD|9MU`b54WBKW1fnfYE-u z`~6SP9;KCUVsg93X~!XLC!EGJS^m)8v(Lke)628X#XGn;y|j*JAM-BmC53#)Hg}*j zVA{QUojV?PyX}T`^-6*UJRkqY`s-@9aMDEkr2D|zgP&5VaNgETCH(LK>ib?&3R4vI ze=>^p0E%voqMxH!nW9kkm4tB%M1+q$5V5aMF$^Py@s=?( z2QajA4BZ}^x*9_XA}Su`zCsWYZ4DSQfA`-ihW-GCVUA(k!*HT&_(Z^`IxgVnlM9pa z>+3as45*-|ZWlc-m(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3C4^iYm+f!sd&9my9+kf z?t+uG-kD@9=`$J2l65rl*j(c*4_I}?OhaFR%6UM=@3qG^o0EZlAvm0?B~em7P-RXvHaSczCD<$T{K^bHzw`9hZT6=VskFHpqUTrquHc4; zag)cyyWfs`siw+HH4VDV9$i~G~412;eHM7|dP0Y}2QnU`^g0TZ{P69NPSrp|m> diff --git a/Schenk_Brandenberger_S2_Aufg4.py b/Schenk_Brandenberger_S2_Aufg4.py index ecfe13e..bee30e5 100644 --- a/Schenk_Brandenberger_S2_Aufg4.py +++ b/Schenk_Brandenberger_S2_Aufg4.py @@ -1,8 +1,38 @@ -def maxPower(base): - x = 0.5 - power = 0 - while x > 0: - power = power + 1 - x = x / base - return power -print(maxPower(2)) \ No newline at end of file + +def eps(base, n): # n = Anzahl Stellen der Mantisse + return 0.5 * (base ** (1-n)) + + +def digitsMantiss(base): # -5*10^-17 + last_x = 0 + x = 1.5 + n = 1 + while x > 1: + last_x = x + x = x - (x - 1) / base + n = n + 1 + return n, last_x + +def largestNumber(digitsMantiss): + x = 0.0 + for i in range(digitsMantiss): + x = x + 2 ** i + return x + +def largestNumber_eps(eps, n): + return eps * 2**(2*n) - 1 + + + + +digMan = digitsMantiss(2) +epsVal = eps(2, digMan[0]) +largest = largestNumber(digMan[0]) +largest_eps = largestNumber_eps(epsVal, digMan[0]) + + +print(f'eps: {epsVal}') +print(f'Digits Mantiss: {digMan[0]}') +print(f'Smallest Number 1 + eps > 1: {digMan[1]}') +print(f'largest Number 1 + qmax > qmax: {largest}') +print(f'largest Number 1 + qmax > qmax (calculated by eps: {largest_eps}') \ No newline at end of file