<div dir="ltr">2018-06-11 19:33 GMT+02:00 Michael Selik <span dir="ltr"><<a href="mailto:mike@selik.org" target="_blank">mike@selik.org</a>></span>:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Whoops, it turns out Euler's formula does work! I expected imprecision, but at least one test matched.<div><br></div><div>x = 42</div><div>cos(x) + 1j * sin(x) == e ** (1j * x)</div></blockquote><div><br></div><div>I think you will find it holds for any x (except inf, -inf and nan).</div><div>The boat is less leaky than you think; IEEE floating-point arithmetic goes</div><div>out of its way to produce exact answers whenever possible.</div><div>(To great consternation of hardware designers who felt that</div><div>requiring 1.0*x == x was too expensive.)<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>I suppose that's because it's radians.</div></blockquote><div><br></div><div>Well, the formula obviously only holds in exact arithmetic <br></div><div>if cos and sin are the versions taking radians.</div><div><br></div><div>Stephan<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div class="h5"><br><br><div class="gmail_quote"><div dir="ltr">On Mon, Jun 11, 2018, 10:24 AM Michael Selik <<a href="mailto:mike@selik.org" target="_blank">mike@selik.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Would sind and cosd make Euler's formula work correctly?<div><br></div><div>sind(x) + i * sind(x) == math.e ** (i * x)</div><div><br></div><div>I suspect that adding these functions is kind of like those cartoons where the boat is springing leaks and the character tried to plug them with their fingers. Floating point is a leaky abstraction.</div><div><br></div><div>Perhaps you'd prefer an enhancement to the fractions module that provides real (not float) math?</div>
</blockquote></div></div></div></div>
<br>______________________________<wbr>_________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/<wbr>codeofconduct/</a><br>
<br></blockquote></div><br></div></div>