Last active
February 5, 2022 19:50
-
-
Save sanchezcarlosjr/b7d9adee444ea4bbd1864fa8c0386dd1 to your computer and use it in GitHub Desktop.
1.1.1 Numerical Analysis Mathematical preliminaries and Error Analysis .ipynb
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
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"name": "1.1.1 Numerical Analysis Mathematical preliminaries and Error Analysis .ipynb", | |
"provenance": [], | |
"collapsed_sections": [], | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3" | |
}, | |
"language_info": { | |
"name": "python" | |
} | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/sanchezcarlosjr/b7d9adee444ea4bbd1864fa8c0386dd1/1-1-1-numerical-analysis-mathematical-preliminaries-and-error-analysis.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"source": [ | |
"Show that the following equations have at least one solution in the given intervals." | |
], | |
"metadata": { | |
"id": "sKwVJhjxQdC_" | |
} | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"id": "kFQHqdA5O8di" | |
}, | |
"outputs": [], | |
"source": [ | |
"def equationHasAtLeastOneSolutionInTheGivenInterval(f, a, b, K):\n", | |
" return min(f(a),f(b)) <= K <= max(f(a),f(b))" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"source": [ | |
"# $(x-2)^2-ln(x)=0,[1,2]\\text{ and } [e,4]$" | |
], | |
"metadata": { | |
"id": "e1TqwzLXQjqp" | |
} | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"from math import log,e\n", | |
"equationHasAtLeastOneSolutionInTheGivenInterval(f=lambda x:(x-2)**2-log(x),a=1,b=2,K=0)" | |
], | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "IcqcTHw9Qwzx", | |
"outputId": "af799032-4b90-4c39-a3ad-49fdc7f3f288" | |
}, | |
"execution_count": null, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"text/plain": [ | |
"True" | |
] | |
}, | |
"metadata": {}, | |
"execution_count": 2 | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"from math import log,e\n", | |
"equationHasAtLeastOneSolutionInTheGivenInterval(f=lambda x:(x-2)**2-log(x),a=e,b=4,K=0)" | |
], | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "OGcZMC9YQjSj", | |
"outputId": "ecd1b405-b67b-4cfb-d7b0-c95abe6a6c75" | |
}, | |
"execution_count": null, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"text/plain": [ | |
"True" | |
] | |
}, | |
"metadata": {}, | |
"execution_count": 3 | |
} | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"source": [ | |
"# $2xcos(2x)-(x-2)^2=0$, $[2,3]$ and $[3,4]$" | |
], | |
"metadata": { | |
"id": "iWk1KQ7SQ6Wi" | |
} | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"from math import cos\n", | |
"equationHasAtLeastOneSolutionInTheGivenInterval(f=lambda x:2*x*cos(2*x)-(2*x)**2,a=2,b=3,K=0)" | |
], | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "BeUVT657RboB", | |
"outputId": "5ea7b1ef-f808-4022-9d36-880dd10f4d9c" | |
}, | |
"execution_count": null, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"text/plain": [ | |
"False" | |
] | |
}, | |
"metadata": {}, | |
"execution_count": 4 | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"from math import cos\n", | |
"equationHasAtLeastOneSolutionInTheGivenInterval(f=lambda x:2*x*cos(2*x)-(2*x)**2,a=3,b=4,K=0)" | |
], | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "NA39VrilRdpt", | |
"outputId": "24e221c7-a824-45c7-e6d2-10b4f88c3de7" | |
}, | |
"execution_count": null, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"text/plain": [ | |
"False" | |
] | |
}, | |
"metadata": {}, | |
"execution_count": 5 | |
} | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"source": [ | |
"# $x-(ln(x))^x=0,[4,5]$" | |
], | |
"metadata": { | |
"id": "_3kk9Of4RuaM" | |
} | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"from math import log\n", | |
"# True\n", | |
"equationHasAtLeastOneSolutionInTheGivenInterval(f=lambda x:x-(log(x))**x,a=4,b=5,K=0)" | |
], | |
"metadata": { | |
"id": "7HXHby3MRyQm", | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"outputId": "c9fb05cc-605b-48d6-ba21-3206bab52355" | |
}, | |
"execution_count": null, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"text/plain": [ | |
"True" | |
] | |
}, | |
"metadata": {}, | |
"execution_count": 6 | |
} | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment