Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Gaussian error function. Erf(y). is defined as: Erf(y) = 2/squareroot pi integral^y_0 e^-x^2 dx Your goal is to write a C program to compute

image text in transcribed

The Gaussian error function. Erf(y). is defined as: Erf(y) = 2/squareroot pi integral^y_0 e^-x^2 dx Your goal is to write a C program to compute Erf(y) foe various values of y. Please follow the following steps: (a) Write a function to compute the integrand of the above function (e^-x^2). The function should have die following prototype double Integrand(double x) (b) Write a general-purpose implementation of any integration algorithm you've seen in this class (midpoint, trapezoidal Simpson. or Monte Carlo). It should have the following prototype: double integral (DfD fp, double a, double b, int n) (Where DfD is defined as: typedef double (*DfD) (double);) fp is a pointer to die function you would like to integrate, a is the left bound, b is the right bound, and n is the number of panels segments (c) Write a function that uses the integral function to evaluate Erf(y). It should have the following prototype: double Erf (double y) Use n=500 panels. An ancient method for finding all primes less than K. for a given N. is known as the sieve of Eratosthenes This algorithm works as follows: 1 Create a list of consecutive integers from 2 to X (2.3.4 ..., N) 2. Let p=2. the first prime number 3. Stalling from 2*p cross off all multiples of p from the list (2p. 3p. 4p. etc.). This can be done by writing 0 in place of the number. Note that some of diem may already have been deleted 4. Change p to the first non-zero value in the list greater than the previous value of p. 5. Repeat this process from step 3 until p is larger than N Write a program (in C or in Fortran) that uses this method to compute a list of all prunes less than 10000

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

Database Driven Web Sites

Authors: Mike Morrison, Joline Morrison

1st Edition

061901556X, 978-0619015565

More Books

Students also viewed these Databases questions