Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in r ggplot2 Riemann and Trapezoid Rule. The error function is a special (non-elementary) function that occurs in probability and statistics. The function is an

image text in transcribedin r ggplot2

Riemann and Trapezoid Rule. The "error function" is a special (non-elementary) function that occurs in probability and statistics. The function is an integral of a Gaussian, and the function depends on the upper limit of the integration. The integral must be solved numerically: erf(b)=0b2ex2dx a. Write an R function (esfuintegsand) for the integrand of the error function 2ex2. Plot the integrand from x=0 to 2 . You can use regular curve or garlat, (see Lab 2 for relevant ggolec example). b. Write a function (sjemano) for the Riemann sum approximation (rectangles) of the integral of a function, f, from a to b with nbjarectangular areas: A=h(f(a+0h)+f(a+1h)+f(a+2h)++f(a+(nbin1)h)) Use a for loop to carry out the running sum of the area. Use this function to estimate erf(2) with nbins =100 and 10000 . An input to your cierang function will include erfrintegrand as well as integration endpoints 0 and 2, and nbins. Compare the estimates with the library (prasma) function erf (2). c. Write a function (trapezoid) for the trapezoid-rule for numerical integration of a function, f, from a to b with bjn trapezoid areas: A=h(f(a)/2+f(ath)+f(a+2h)++f(a+(nbin1)h)++f(b)/2) Use a for loop to carry out the running sum areas. Use this function to estimate erf(2) with nbins =100 and 10000 . Compare the accuracy with the library (paamas) function erf(2) and with the library (prasma ) function quad. Use ?mad to see how it works. Is Riemann or trapezoid a better algorithm? d.. Estimate Pi. Use Riemann and the trapezoid rule to estimate by integrating the area under the curve for a quarter circle with unit radius: f(x)=1x2. First plot the f(x) from 0 to 1. This f(x) is your integrand and you need to multiply the area by 4 to estimate . How many bins does each method need to get 5 digits of precision for

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

Students also viewed these Databases questions

Question

7. What is the role of an advertising agency?

Answered: 1 week ago

Question

b. What is the probability of winning? Pg45

Answered: 1 week ago