Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using Python 2 the 2 functions referenced def midpoint_integration(f, a, b, n=100): h = (b - a)/float(n) I = 0 for i in range(n): I

Using Python 2
image text in transcribed
the 2 functions referenced image text in transcribed
image text in transcribed
def midpoint_integration(f, a, b, n=100): h = (b - a)/float(n) I = 0 for i in range(n): I += f(a + i*h = 0.5*h) return h*I 8 9 10 11 12 13 14 15 16 from math import * import sys f_formula = sys.argv[1] a = eval(sys.argv[2]) b = eval(sys.argv[3]) if len(sys.argv) >= 5: n = int(sys.argv[4]) else: n = 200 17 18 19 20 code = " def g(x): return $s % f_formula exec(code) 21 22 23 24 25 I = midpoint integration(g, a, b, n) print 'Integral of %s on %, *g) with n=d: %' % (f_formula, a, b, n, I) useful, we have made a special tool that hides the technicalities. The tool is named StringFunction and works as follows: >>> from scitools.StringFunction import StringFunction >>> formula = exp(x)*sin(x)' >>> f = StringFunction(formula) # turn formula into f(x) func

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

37. Find Var(X) and Var(Y) for X and Y as given in Problem 21.

Answered: 1 week ago

Question

discuss the layers of the TCP / IP model

Answered: 1 week ago

Question

Discuss the history of human resource management (HRM).

Answered: 1 week ago