Created
June 19, 2017 12:30
-
-
Save genkuroki/9cd0226a07cb7c529f15de1c9b36866b to your computer and use it in GitHub Desktop.
2017-06-17-192450sagemath.ipynb SageMath Integration Example
This file contains 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
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"collapsed": false | |
}, | |
"source": [ | |
"#SageMath" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 23, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<html><script type=\"math/tex; mode=display\">\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\frac{1}{2} \\, \\pi + \\pi a - \\pi \\sqrt{a^{2} + a}</script></html>" | |
] | |
}, | |
"execution_count": 23, | |
"metadata": { | |
}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"var('x, a')\n", | |
"assume(a>0)\n", | |
"f(x)=sqrt(x*(1-x))/(x+a)\n", | |
"#show(integral(f(x),x))\n", | |
"show(integrate(f(x),x,0,1))" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 24, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<html><script type=\"math/tex; mode=display\">\\newcommand{\\Bold}[1]{\\mathbf{#1}}{\\left(a + b\\right)} \\arcsin\\left(-\\frac{\\sqrt{a^{2} - 2 \\, a b + b^{2}}}{a - b}\\right) - 2 \\, \\sqrt{a b} \\arcsin\\left(-\\frac{\\sqrt{a^{2} - 2 \\, a b + b^{2}}}{a - b}\\right)</script></html>" | |
] | |
}, | |
"execution_count": 24, | |
"metadata": { | |
}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"var('x,a,b')\n", | |
"assume(a<b)\n", | |
"f(x)=sqrt((x-a)*(b-x))/x\n", | |
"#show(integral(f(x),x))\n", | |
"show(integrate(f(x),x,a,b))" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 0, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
], | |
"source": [ | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "SageMath (stable)", | |
"name": "sagemath" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 2 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython2", | |
"version": "2.7.13" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment