• Welcome to the new Internet Infidels Discussion Board, formerly Talk Freethought.

The Calculus Thread

Back to Gaussian integration. In general,

integral for x from xa to xb of wi(x)*f(x) = sum over i of wp(i) * f(x(i))

where one uses for the x(i) the roots of the polynomial for the integral weighting wi(x) and limits xa, ab, and finds the point weighting wp(i) from each x(i).

The most familiar kind is  Gauss–Legendre quadrature with constant integral weighting.

There exist other types, like  Chebyshev–Gauss quadrature and  Gauss–Jacobi quadrature and  Gauss–Laguerre quadrature and  Gauss–Hermite quadrature with integral weighting appropriate for each one.

There are also variations of Gauss-Legendre integration with constant integral weighting and one or both limits of integration as points. For one limit, it is Gauss-Radau, and for both limits, it is Gauss-Lobatto. The points are at roots of polynomials related to Legendre polynomials.
 
A calc 101 question

ys = sin(x) 0 to 2*pi
yl is a line passing through (0,pi) intersecting ys at x = pi/4

What is the area above the line yl bounded by the curve ys?

Take a shot before looking it up. Algebra and area.

A practical problem in mechanics when machining arbitrary surface contours in metal objects and calculating the remaining mass after material is removed, in 3D.

Given in the above problem the material is a thin metal plate with a density of 1kg/m^2. What is the mass repressed by the solution, the area between the two curves?

The area s scaled in kg/m^2.
 
Te first thing to do is make a sketch of a half sine 0-pi and the lone. The end points of the line are siin(pi/4) = .707 and sin(pi) = 0.

Integral sin is -cos. Calculate area over pi/4 to pi.

The line forms a right triangle, kculte area.

Subtract triangle area from sine curve area.

It is easy because both curves are in the 1st quadrant, no zero crossings. The area of sin 0 to pi is 2, pi to 2pi is -2. The area of a sin 0 to 2pi is numerically zero.

Interrogations can get complicated.


Code:
//Scilab script
//area between curves

clear
clc
xhi = %pi
xlo = %pi/4
n = 10000
dx = (xhi - xlo)/n
x = [xlo:dx:xhi]'
ys = sin(x)
//find equation of the line
m = ( sin(xlo) - sin(xhi) ) / (xlo - xhi)  // slope dy/dx
b = sin(xlo) - m*xlo
yl = m*x + b

s = 0
//numerical integration
for i = 1:n
    s = s + (ys(i)-yl(i))*dx
 end
 
 // find total area subtract sub area
 asin = cos(%pi/4)  - cos(%pi) //area sine pi/4 to pi
 a_under_line = (%pi - %pi/4)*sin(%pi/4)/2 //area right triangle
 a_above_line = asin - a_under_line  // area above yl bounded by ys
 mprintf("calculated  %f  numerical  %f\n",a_above_line,s)
 
 
w1 = scf(1)
clf(w1)
plot2d(x,ys)
plot2d(x,yl)
xgrid

calculated 0.874066 numerical 0.874066
 
When applying integrals there can be a problem with zero mean areas.


First radians and degrees, A circle is divided into 360 degrees. The circumference of a circle radius 1 is 2*pi. 360 degrees = 2*pi radians,

Handy reference points
radians -- degrees
0 0
pi/4 45
2*pi/4 90
3*pi4 135
pi 180
2*pi 360

Integral sin 0-2*pi = cos(2*pi)-cos(o) = 0.

In electronics the area of a waveform can represent energy. Put a sine wave of current through a resistor and it will heat up, So using the direct area or average value of a function has no value.

A metric to compare integrals in terms of energy is RMS or root mean squared integral.

Scroll down to the integral.


It is said that any signal with the same RMS value represents the same energy. Electronic equipment will sample a signal and numerically integrate a data set to get the RMS value.

RMS of a sine = 0.7071068

As an exercise you can plug sine(x) into the formula for 0-2^pi and work out the integral.

If you are familiar with statistics it is the standard deviation.

Root mean square a variation applies to equipartition of energy in physics.

Code:
//Scilab script
clear
clc
xhi = %pi*2
xlo = 0
n = 10000
dx = (xhi - xlo)/n
x = [xlo:dx:xhi]'
ys = sin(x)
s = 0
for i = 1:n
        s = s +  (ys(i)^2 * dx)
end

rms = sqrt(s/(xhi-xlo))
disp(rms)
 
Back
Top Bottom