Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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