Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

T'his homework is basically a mashup of these two studio questions: you should create a main program that computes an approximation to the integral f(z)dr

image text in transcribed
T'his homework is basically a mashup of these two studio questions: you should create a main program that computes an approximation to the integral f(z)dr where the (math) function f(a) is defined in a C++function whose prototype is float myfcn(float); The key part here is that f(z) should be implemented only in the C++ function myfcn. You wil have done things correctly if you can first make nyfcn implement f(x) cos(for which the exact integral is 2 sin(1) 1.68294 ), and then change to f(x)-14 + 2x (exact integral 0.4) by changing only the code inside myf cn (and nowhere else!) Just like in studio, we will approximate the integral by dividing the z axis into a number of segments, approximating the area of each segment assuming it's a trapezoid i.e., assuming that the function varies linearly within that segment), and then adding up the areas from all segments to get the total integral. A new thing is that your program should now read in the number of segments N from the keyboard. This means that your points should be spaced a distance | = 2/N apart You wil need to create an x array to hold these values. Make this array really long, say 1000 elements, to make sure you will never overrun it (i.e., your program will then work for N

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

Recommended Textbook for

SQL Antipatterns Avoiding The Pitfalls Of Database Programming

Authors: Bill Karwin

1st Edition

1680508989, 978-1680508987

More Books

Students also viewed these Databases questions

Question

Create the ERD to show the relationship between STORE and REGION.

Answered: 1 week ago