Post Reply 
Integral puzzle with absolute value function
12-09-2019, 08:51 PM (This post was last modified: 12-09-2019 09:48 PM by Albert Chan.)
Post: #1
Integral puzzle with absolute value function
Inspired from thread Error when integrating absolute value

This is a puzzle I created, with a *very simple* solution.
With m,n both positive integers, q = pi/2, solve for I:

\(\large I = \int _0 ^{m q} \int _0 ^{n q} |\sin(x+y)\,| dx\,dy \)

Hint: period of integrand has period of pi = 2q
Find all posts by this user
Quote this message in a reply
12-09-2019, 10:46 PM
Post: #2
RE: Integral puzzle with absolute value function
My wild guess is mn but I've not tried working it out.

Pauli
Find all posts by this user
Quote this message in a reply
12-10-2019, 03:46 PM (This post was last modified: 12-10-2019 08:07 PM by Albert Chan.)
Post: #3
RE: Integral puzzle with absolute value function
(12-09-2019 08:51 PM)Albert Chan Wrote:  With m,n both positive integers, q = pi/2, solve for I:

\(\large I = \int _0 ^{m q} \int _0 ^{n q} |\sin(x+y)\,| dx\,dy \)

Hint: period of integrand has period of pi = 2q

Lets create a shorthand: I = (m Θ 0) • (n Θ 0) = m • n
Let m = 2a + b, n = 2c + d, where b,d = 0 or 1

\(I = m • n = (2a + b) • (2c + d) = ac (2 • 2) + (ad + bc) (1 • 2) + bd (1 • 1)\)

\( 1 • 1 = \int _0 ^{q} \int _0 ^{q} \sin(x+y)\ dx\,dy
= \int _0 ^{q} -\cos (x+y) | _0 ^q\;dy
= \int _0 ^{q} (\cos y + \sin y) \;dy = 1 + 1 = 2 \)

\( 2 • 2 = \int _0 ^{\pi} \left( \int _y ^{\pi} \sin u\ du
- \int _{\pi} ^{\pi+y} \sin u \ du \right)\,dy
= \int _0 ^{\pi} (1+\cos y) - (-1+\cos y) \; dy
= \int _0 ^{\pi} 2 \; dy = 2 \pi \)

\( 1 • 2 = \int _0 ^{q} 2 \; dy = \pi \)

Since (2 • 2) = 2(1 • 2), we have: \(\large I = m • n = \lfloor mn / 2 \rfloor \pi + 2 \bmod(mn, 2) \)
Find all posts by this user
Quote this message in a reply
12-10-2019, 05:30 PM (This post was last modified: 12-10-2019 10:08 PM by Albert Chan.)
Post: #4
RE: Integral puzzle with absolute value function
I with non-zero lower limit, we can simply expand the "products" (assumed d ≥ c, b ≥ a)

I = (d Θ c) • (b Θ a) = (d • b) - (d • a) - (c • b) + (c • a)

Example: (8 Θ 3) • (7 Θ 2) = (28 pi) - (8 pi) - (10 pi + 2) + (3 pi) = 13 pi - 2

But there is an easier way:
Code:
r = (d-c) * (b-a)
I = (r//2) * pi
if odd(r): I += (pi-2) if odd(a+c) else 2

Redo same example: r = (8-3) × (7-2) = 25 = 26 - 1               → I = 13 pi - 2

Prove: with integrand period of 2q, we can shift the limit, into 3 cases.
Above example is last case: (5 Θ 0) • (6 Θ 1) = (15 pi) - (2 pi + 2) = 13 pi - 2

1). (d Θ 0) • (b Θ 0) = d • b (same as previous post)

2). (d Θ 1) • (b Θ 1) = (d • b) - (d • 1) - (b • 1) + (1 • 1)
Tried all combinations ((b+d) odd, and even), above = (d - 1) • (b - 1)

3). (d Θ 0) • (b Θ 1) = (d • b) - (d • 1)                                      // a+c is odd

If r = d(b-1) is even, above = d • (b - 1)

If r is odd, above = (½ d b pi) - (½(d-1) pi + 2) = ½(db - d - 1) pi + (pi - 2)
However, d • (b - 1) = ½(db - d - 1) pi + 2
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)