Question: use python Problem 2. Write a Python function romberg (func, a, b, eps, *P) which computes the integral of the given function between the given
use python
Problem 2. Write a Python function romberg (func, a, b, eps, *P) which computes the integral of the given function between the given limits, using Romberg integration to obtain a solution to within an error of approximately eps. Use this function to solve the following problem. The flux leaving a square centimeter of a blackbody radiator at temperature T is F = oT4 (where o is the Stephan-Boltzmann constant). This is the result of integrating the flux from a Plank spectrum over all frequencies 01' = + ( B(T) dv Jo where the Planck function is BxT) = 2hyam {ethu k 1}" Start by reducing the integral to po 23 dx Jo el - 1 by a change of variable. Use your Romberg integration function to obtain the value of this integral and evaluate o in the units of your choice. Check your answer against the correct value. Note that this and the next problem present integrals with several mathematical diffi- culties. The integral above is singular at the origin and both this and the next problem are integrals with an infinite range. HINT: Note that both integrands go rapidly to zero outside a quite narrow range in x. How large a range of integration does one need, in either case, to achieve an approxi- mation to a given precision? Problem 2. Write a Python function romberg (func, a, b, eps, *P) which computes the integral of the given function between the given limits, using Romberg integration to obtain a solution to within an error of approximately eps. Use this function to solve the following problem. The flux leaving a square centimeter of a blackbody radiator at temperature T is F = oT4 (where o is the Stephan-Boltzmann constant). This is the result of integrating the flux from a Plank spectrum over all frequencies 01' = + ( B(T) dv Jo where the Planck function is BxT) = 2hyam {ethu k 1}" Start by reducing the integral to po 23 dx Jo el - 1 by a change of variable. Use your Romberg integration function to obtain the value of this integral and evaluate o in the units of your choice. Check your answer against the correct value. Note that this and the next problem present integrals with several mathematical diffi- culties. The integral above is singular at the origin and both this and the next problem are integrals with an infinite range. HINT: Note that both integrands go rapidly to zero outside a quite narrow range in x. How large a range of integration does one need, in either case, to achieve an approxi- mation to a given precision
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
