Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "cells": [
- {
- "cell_type": "code",
- "execution_count": 1,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Límite inferior: 1\n",
- "Límite superior: 2\n",
- "Num de segmentos: 4\n",
- "\n",
- "N de segmentos Integral Et\n",
- " 1 6.500000000 12.601127625\n",
- " 2 5.972222222 3.458301023\n",
- " 3 5.863333333 1.571991535\n",
- " 4 5.824070295 0.891828086\n"
- ]
- }
- ],
- "source": [
- "import math\n",
- "\n",
- "\n",
- "a=float(input(\"Límite inferior: \"))\n",
- "b=float(input(\"Límite superior: \"))\n",
- "n=int(input(\"Num de segmentos: \"))\n",
- "\n",
- "print(\"\")\n",
- "print(\"{0:>10s}{1:>15s}{2:>15s}\".format(\"N de segmentos\", \"Integral\", \"Et\"))\n",
- "\n",
- "vv=5.7725887272\n",
- "fa = ((a+2)/a)**2\n",
- "fb = ((b+2)/b)**2\n",
- "h = (b-a)/n\n",
- "\n",
- "for k in range (n) :\n",
- " sum=fa\n",
- " h = (b-a)/(k+1)\n",
- " for i in range (1,k+1) :\n",
- " xi = a+(i*h)\n",
- " fxi = ((xi+2)/xi)**2\n",
- " sum = sum+(2*fxi)\n",
- " \n",
- " sum = sum + fb\n",
- " sum = h*(sum/2)\n",
- " I = h*(sum/2)\n",
- " Et=abs((vv-sum)/vv)*100\n",
- " print(\"{0:10d}{1:20.9f}{2:20.9f}\".format(k+1, sum , Et))"
- ]
- }
- ],
- "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.7.2"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 2
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement