Created
February 16, 2019 00:55
-
-
Save jctanner/3b6009d55594968f3d4af0d0531f6664 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# make the n divisions for a=0 b=1 n=8 | |
[jtanner@jtw530 ~]$ python -c 'import numpy as np; print([x*.125 for x in range(0,9)])' | |
[0.0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875, 1.0] | |
# find f(x) for each division | |
[jtanner@jtw530 ~]$ python -c 'import numpy as np; print([np.exp(x*.125) for x in range(0,9)])' | |
[1.0, 1.1331484530668263, 1.2840254166877414, 1.4549914146182013, 1.6487212707001282, 1.8682459574322223, 2.117000016612675, 2.398875293967098, 2.718281828459045] | |
# add all the f(x) values | |
[jtanner@jtw530 ~]$ python -c 'import numpy as np; print(sum([np.exp(x*.125) for x in range(0,9)]))' | |
15.623289651543937 | |
# multiply the sum of f(x)'s by dx | |
[jtanner@jtw530 ~]$ python -c 'import numpy as np; print(sum([np.exp(x*.125) for x in range(0,9)]) * .125)' | |
1.952911206442992 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment