{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import mpmath as mp" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from mpmath import *" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [], "source": [ "g=lambda t,y: mp.exp(t/2)*(mp.sqrt(t)/(2*j*mp.sqrt(2*mp.pi)))*(mp.erf((t+2*y)/mp.sqrt(2*t))+mp.erf((t-2*y)/mp.sqrt(2*t)))-mp.exp(t/8)*mp.cosh(y)*(mp.sqrt(t)/(j*mp.sqrt(2*mp.pi)))*(mp.erf((t+4*y)/(2*mp.sqrt(2*t)))+mp.erf((t-4*y)/(2*mp.sqrt(2*t))))" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [], "source": [ "g_full=lambda sigma, t, u: g(t*sigma^2,u-j*mp.pi/2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The output from the next evaluation is from evaluating the notebook with Python 3.5 (or 3.4). The result is wrong." ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "mpc(real='2.7466497341365184', imag='-1.2252659095292708')" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "g_full(1,1,1)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This is the output when executing the above line of code and the entire notebook with Python 2.7. The result is the correct one." ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "mpc(real='1.6615578111551215', imag='-0.48315211896889476')" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "g_full(1,1,1)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.5.1" } }, "nbformat": 4, "nbformat_minor": 0 }