Question: can someone convert either of thes two into MATHEMATICA PSEUDOCODE function integral = simpsonsFunc(f,a,b,n) h = (b-a)/n; x = linspace(a,b,n); x4=0; x2=0; for j=2:2:b x4

can someone convert either of thes two into MATHEMATICA PSEUDOCODE

function integral = simpsonsFunc(f,a,b,n) h = (b-a)/n; x = linspace(a,b,n); x4=0; x2=0; for j=2:2:b x4 = x4 + f(x4); end for k=3:2:b x2= x2 + f(x2); end integral = (h/3)*(f(a)+ f(b) + 4*(x4)+ 2*(x2)); end ******************************************************

I've also written a python code for the same:

****************************************************** def simpson(f, a, b, n): h=(b-a)/n k=0.0 x=a + h for i in range(1,n/2 + 1): k += 4*f(x) x += 2*h

x = a + 2*h for i in range(1,n/2): k += 2*f(x) x += 2*h return (h/3)*(f(a)+f(b)+k)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!