Shapes & spaces

Oscillatory sine and cosine weighted integral calculator

Integrate a smooth real amplitude against a sine or cosine carrier while retaining the carrier phase analytically within each panel.

Your numbers

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

Integrate a smooth real amplitude against a sine or cosine carrier while retaining the carrier phase analytically within each panel.

THE FORMULAI=∫_a^b f(x) cos(ωx) dx or ∫_a^b f(x) sin(ωx) dx; polynomial amplitude approximations are combined with oscillatory moments.

A worked example

For f(x)=exp(-x), [0,1], omega=20 and cosine weight, I=[1+exp(-1)(-cos(20)+20 sin(20))]/401 ≈ 0.0188702014271921.

Good to know

Finite interval, real smooth amplitude expression and frequency omega, |omega*(b−a)|≤100000; adaptive 12/24-degree Chebyshev amplitude interpolation, analytical/recurrence sine-cosine moments and phase-aware subdivision. Cap 512 panels and reject failed moment recurrence/refinement. Handle omega=0 by nonoscillatory limit; no nonlinear stationary phase or infinite Fourier tail.

Separate amplitude from the carrier

Enter the slowly varying real function as the amplitude and select sine or cosine as the carrier. Frequency omega is angular frequency in radians per x unit, so a full cycle has width 2π divided by the magnitude of omega. The phase convention is omega times the original coordinate x, not omega times the displacement from the interval start.

If a signal is given in cycles per second, multiply its ordinary frequency by 2π before using seconds as x. Do not include the sine or cosine factor again in the amplitude. That would introduce a second oscillation and invalidate the intended decomposition. A phase-shifted carrier can instead be expressed as a linear combination of the sine and cosine results under the same coordinate convention.

A carrier oscillates inside its envelopeAmplitude envelope exp(−x)Carrier cos(20x); signed cancellation
Scroll across to see the full diagram.
Opposite signed panel contributions can cancel although the amplitude remains positive.

Compare this with the Gauss–Legendre quadrature calculator with nodes and weights. Existing generic Gauss quadrature samples the entire oscillating product. This page integrates a smooth amplitude against a supplied linear sine/cosine phase through oscillatory Chebyshev moments, resolving high frequency without one node per oscillation.

Why ordinary sampling can miss the answer

Rapidly oscillating positive and negative contributions cancel. A generic mesh can accidentally sample similar phases and return a plausible but wrong estimate, especially when the interval contains many cycles. The small final answer may result from cancellation among much larger panel contributions, so matching a rough amplitude envelope does not guarantee an accurate weighted integral.

The carrier-aware approach approximates only the amplitude on each panel. It then integrates the polynomial approximation against sine or cosine moments without resolving every oscillation by ordinary point sampling. This separates the frequency scale from the amplitude variation scale. Adaptive subdivision still matters because a smooth expression can change sharply in a narrow region, and a low-degree panel approximation must detect that change.

Use moments with stable frequency limits

Chebyshev approximations of degrees twelve and twenty-four provide a local refinement comparison. Their coefficients combine with integrals of Chebyshev polynomials times the oscillatory carrier. Stable moment evaluation needs more than one numerical regime: small dimensionless panel frequency is handled near its nonoscillatory limit, while larger frequencies require a recurrence or equivalent analytic construction with controlled cancellation.

At omega equal to zero, cosine weight is exactly one and sine weight is exactly zero. Dividing by powers of omega without a limiting branch creates an artificial singularity that the integral does not have. Negative frequencies also provide a useful check: the cosine result is even in omega, whereas the sine result is odd. Those identities hold for every accepted real amplitude and interval.

Check the exponential example analytically

For the default amplitude exp(-x), differentiate exp(-x)(-cos(omega*x)+omega*sin(omega*x))/(1+omega²). The derivative is exp(-x)cos(omega*x), so evaluating at zero and one produces the exact expression in the worked example. At omega=20 the denominator is 401 and the result is approximately 0.0188702014271921.

The corresponding sine integral is [20-exp(-1)(sin(20)+20*cos(20))]/401. These expressions offer independent references across positive, negative and small frequencies. They also reveal the cancellation scale: the integral is much smaller than the integral of the positive amplitude alone. Use absolute error when comparing near a zero, because a relative percentage can become arbitrarily large for a tiny but accurately computed result.

Read panel diagnostics and the figure

The illustration places a rapidly changing carrier inside a slowly varying envelope, then shows signed panel contributions. Positive and negative bars can nearly cancel while the overall amplitude stays strictly positive. That cancellation is expected mathematical behavior. A result close to zero does not imply that the integrand was small or that every panel contributed little area.

The refinement diagnostic compares two amplitude approximations and tracks accepted subdivisions. A failed moment recurrence or a panel cap must remain an unresolved numerical status. The page should report the achieved residual comparison and number of panels rather than claiming a universal error certificate. Inspect amplitude behavior near endpoints and narrow peaks if repeated subdivision fails, since frequency alone does not describe all sources of difficulty.

Keep the supported oscillation model explicit

The maximum accepted phase span is |omega*(b-a)| equal to one hundred thousand, and the panel cap is five hundred twelve. The interval is finite and the amplitude is assumed smooth. Expressions with absolute-value corners, jumps or singular endpoints may require manual interval splitting or a different integration family. The page does not silently reinterpret such features as smooth data.

A nonlinear phase such as sin(x²) has varying instantaneous frequency and possible stationary points. Putting it in the amplitude does not turn this fixed-frequency method into a stationary-phase algorithm. Infinite Fourier tails also involve convergence and truncation questions absent from a finite interval. Restrict conclusions to the stated carrier, interval and amplitude rather than treating the output as a general Fourier-transform guarantee.

Use comparisons that expose aliasing

A reliable cross-check changes mathematical structure: compare an analytic antiderivative, integration by parts, an independent weighted integrator or a frequency-symmetry identity. Merely doubling a uniform sample count can preserve the same phase coincidence and produce false reassurance. For constant amplitude, elementary sine and cosine antiderivatives give convenient high-frequency tests without introducing approximation error from the amplitude.

Changing the coordinate origin also changes carrier phase, so translate the expression consistently. For a shifted interval, cos(omega*(a+t)) expands into a cosine and sine combination in t. Forgetting that phase gives a different integral even when the interval length is unchanged. Keeping the original-coordinate convention visible makes saved results reproducible and prevents an apparently harmless rescaling from changing the mathematical question.

A few questions, answered

Is omega measured in cycles?

No. It is angular frequency in radians per x unit.

What happens at zero frequency?

Cosine becomes ordinary integration of the amplitude, while sine gives zero.

Can I enter sin(x²)?

The carrier is linear in x. Nonlinear-phase integration is outside this method.

Why can the result be tiny?

Large positive and negative oscillatory contributions can cancel almost completely.

Find your calculator

Start typing to explore the library.