Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. {
  2. "cells": [
  3. {
  4. "cell_type": "markdown",
  5. "metadata": {},
  6. "source": [
  7. "# Tarea\n",
  8. "Aplicando la regla de Simpson 1/3 múltple (n=4) elabore un\n",
  9. "programa en Jupyter-Python para resolver el siguiente ejercicio:\n",
  10. "$\\int_{0}^{3}x^{2}e^{x}dx$\n",
  11. "\n",
  12. "\n",
  13. "Oscar Padilla A01740410"
  14. ]
  15. },
  16. {
  17. "cell_type": "code",
  18. "execution_count": 5,
  19. "metadata": {},
  20. "outputs": [
  21. {
  22. "name": "stdout",
  23. "output_type": "stream",
  24. "text": [
  25. "insertar la cantidad de segmentos 4\n",
  26. "Insertar subintervalo a 0\n",
  27. "Insertar subintervalo b 3\n",
  28. "-----------------------------------------------\n",
  29. " Integral Et(%)\n",
  30. "-----------------------------------------------\n",
  31. " 99.456833 1.045675666\n"
  32. ]
  33. }
  34. ],
  35. "source": [
  36. "import math\n",
  37. "n=int(input(\"insertar la cantidad de segmentos \"))\n",
  38. "a=int(input(\"Insertar subintervalo a \"))\n",
  39. "b=int(input(\"Insertar subintervalo b \"))\n",
  40. "print(\"-----------------------------------------------\")\n",
  41. "print(\"{0:>10s}{1:>20s}\". format(\"Integral\", \"Et(%)\"))\n",
  42. "print(\"-----------------------------------------------\")\n",
  43. "Fa=(a**2)*math.exp(a)\n",
  44. "Fb=(b**2)*math.exp(b)\n",
  45. "sum=Fa\n",
  46. "h=(b-a)/n\n",
  47. "Fbh=((b-h)**2)*math.exp(b-h)\n",
  48. "v=98.4276\n",
  49. "for i in range(1,n-1,2):\n",
  50. " xi=a+(i*h)\n",
  51. " Fxi=(xi**2)*math.exp(xi)\n",
  52. " Fxih=((xi+h)**2)*math.exp(xi+h)\n",
  53. " sum=sum+(4*Fxi)+(2*(Fxih))\n",
  54. "sum=sum+(4*Fbh)+Fb\n",
  55. "va=h*sum/3\n",
  56. "et=abs((v-va)/v)*100\n",
  57. "print(\"{0:10f}{1:20.9f}\".format(va,et))"
  58. ]
  59. },
  60. {
  61. "cell_type": "code",
  62. "execution_count": null,
  63. "metadata": {},
  64. "outputs": [],
  65. "source": []
  66. }
  67. ],
  68. "metadata": {
  69. "kernelspec": {
  70. "display_name": "Python 3",
  71. "language": "python",
  72. "name": "python3"
  73. },
  74. "language_info": {
  75. "codemirror_mode": {
  76. "name": "ipython",
  77. "version": 3
  78. },
  79. "file_extension": ".py",
  80. "mimetype": "text/x-python",
  81. "name": "python",
  82. "nbconvert_exporter": "python",
  83. "pygments_lexer": "ipython3",
  84. "version": "3.7.4"
  85. }
  86. },
  87. "nbformat": 4,
  88. "nbformat_minor": 2
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement