Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a function to integrate a function fun(x) from A to B using the trapezoidal rule. Your function should have 3 arguments: A, B and
Write a function to integrate a function fun(x) from A to B using the trapezoidal rule. Your function should have 3 arguments: A, B and N (the number of intervals)
so we want .
for the function use
but this should also be written as a function .. not imbedded in your quadrature function so like: function fun(x)
(x-sin(x^3)-exp(-0.01*x))/(x+exp(0.01*x))
end
Then use the function in your quadrature function.
(recall h = (B-A)/N)
2. Write a program which prompts the user to enter A, B and N. You may assume the user will enter numbers, but you should check to see that N is an integer. A and B can be either integers or real numbers. Your program should then print out
The integral of fun(x) from A to B using N intervals is xxxx
(obviously print out the values A,B and N not A B and N
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started