Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Requirements: Write a script and 3 functions. Write the program to cycle until the users chooses to stop. The script will have an outer while

Requirements:
Write a script and 3 functions. Write the program to cycle until the users chooses to stop.
The script will have an outer while loop and use dialog boxes and switch case statements as described below.
The three functions are as follows:
(note a below is the left value of x and b is the right value of x in the interval of interest)
a. Integrate a function using the Trapezoidal Method, inputs are f(x) function, a,b, and n(# of slices), output is the
integral value.
b. Integrate a function using the Simpson Method, inputs are f(x) function, a,b, and n(# of slices), output is the
integral value.
c. Find the ROOT of a function using the ROOTS algorithm, inputs are f(x) function, a,b, and epsilon( a small # 1),
output is the final root of f(x).
Script flow should be as follows:
Using a Dialog button with 3 buttons (see For_vs _While.m file) have the user chose one of the 3 anonymous
functions. The selected Anonymous function will be used in the three Programmed functions (1) Integral by
Trapezoidal Method, (2) Integral by Simpson Method, or (3) Root by BiSection Method.:
a.f(x)=2**x???5-3**x???2-5(NOTE integral about 206, root about 1.4. Method can affect accuracy for both
solutions use a=1,b=3 slices and epsilon of your choice but greater than 200 I recommend 500)
b.f(x)=x???2-5(Note you should be able to set any range for integral and a specific range for one of the 2
roots)
c. You pick the 3rdf(x) but be sure you can define a range for the roots
Using an input statement ask the user to pick Trapezoidal, Simpson, or ROOT. Make sure you are consistent
with string or number. You can use what you are comfortable with. The input variable will then be used in a
switch case statement. Each case will do the following:
a. First case (Trapezoidal Integral)
i. Ask the user for the inputs a,b, and nf(x) function was already chosen in 1
ii. Call the function with parameters f,a,b,n.f is f(x) from the anonymous selection above.
iii. Use fprintf to output the answer
b. Second case (Simpson Integral)
i. Ask for the three inputs a,b, and nf(x) function was already chosen
ii. Call the function with parameters f,a,b,n.f is f(x) from the anonymous selection above.
iii. Use fprintf to output the answer
c. Third case (ROOTs)
i. Ask for the three inputs a,b, and ef(x) function was already chosen
ii. Call the function with parameters f,a,b,e.f is f(x) from the anonymous selection above.
Remenber e is a very small # 1 e.g.10???(-6) or 10???(-8)
Special NOTE use 10???-2,10???-6, and 10???-10 on 3 different runs to compare the accuracy of the
answer you get.
iii. Use fprintf to output the answer
Write three functions:
a. Integral by Trapezoidal method
b. Integral by Simpson Method
c. Find Root
These functions inputs and output are described above. The INTEGRATION & ROOT doc describes the algorithm
inside these functions.
EXTRA CREDIT 10pts: For Item 2 instead of input statement use a second dialog box with buttons.
image text in transcribed

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

International Baccalaureate Computer Science HL And SL Option A Databases Part I Basic Concepts

Authors: H Sarah Shakibi PhD

1st Edition

1542457084, 978-1542457088

More Books

Students also viewed these Databases questions