Loading [MathJax]/jax/output/CommonHTML/jax.js

2017年8月31日木曜日

学習環境

オイラーの贈物―人類の至宝eiπ=-1を学ぶ (吉田 武(著)、東海大学出版会)の第II部(関数の定義(Definitions of Functions))、第5章(テイラー展開(Taylar's Expansion))、5.3(一般の二項展開)、問題3.を取り組んでみる。


  1. 25718=(1+28)18=2(128+1)18=2(1+128)182(1+18·128)=2+1210=2+110242.000977

コード(Emacs)

Python 3

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from sympy import pprint, Rational, sqrt

print('3.')
x = 257 ** Rational(1, 8)
pprint(x)
pprint(float(x))

x = sqrt(sqrt(sqrt(257)))
pprint(x)
pprint(float(x))

入出力結果(Terminal, IPython)

$ ./sample3.py
3.
8 _____
╲╱ 257 
2.0009748976330775
8 _____
╲╱ 257 
2.0009748976330775
$

HTML5

<pre id="output0"></pre>
<button id="run0">run</button>
<button id="clear0">clear</button>

<script src="sample3.js"></script>    

JavaScript

let pre0 = document.querySelector('#output0'),
    btn0 = document.querySelector('#run0'),
    btn1 = document.querySelector('#clear0'),
    p = (x) => pre0.textContent += x + '\n';

let output = () => {
    pre0.textContent = '';

    p(`257^1/8 = ${257 ** (1 / 8)}`);
    p(`√√√257 = ${Math.sqrt(Math.sqrt(Math.sqrt(257)))}`);
};

btn0.onclick = output;
btn1.onclick = () => pre0.textContent = '';
output();
257^1/8 = 2.0009748976330775
&#8730;&#8730;&#8730;257 = 2.0009748976330775

0 コメント:

コメントを投稿