Question re: Chebyshev Polynomials (and the 'cheby' examp)

👽'tW∆s ∆lienz👽's icon

Been trying to understand Chebyshev Polynomials, and discovered the "cheby" example patch... now i have some basic questions which are best described by/within this patch:

Max Patch
Copy patch and select New From Clipboard in Max.

and just to summarize here in the thread:
1) passing a cosine wave through the 3rd polynomial doesn't seem to behave as described in the example, what am i missing there? (am i taking it too literally and perhaps it only applies in the exact wavetable-lookup context of the example patch?)

2) if i were to use the polynomials exactly as in my patch(not by waveshaping-lookup as in the example), can anyone tell me a general equation which might keep the altered shape, but scale it back down within the -1/+1 range?

Thanks in advance for any illumination anyone can provide 🙏

volker böhm's icon

note: [pow~] has its inlets reversed to what one might think...

👽'tW∆s ∆lienz👽's icon

ahhhhh, that was it! Thank you so much, Volker! (i was used to the way 'pow' works in gen~ and expr, didn't even realize) That answers everything for me. 🍻
[Edit: and there i was tagging this thread "advanced" 😆 hahaha... simple mistake, sorry folks 😇]

volker böhm's icon

I fell for this one a couple of times before...

Roman Thilenius's icon


haha, i never understood what is the rule. i also only use other people´s examples with 3 and 4 polynoms and i was never able to make up a fifth from them.

👽'tW∆s ∆lienz👽's icon

i never understood what is the rule

I'm not sure i understand any rule for the power-based polynomials either 😂(couldn't find any easy 'causal' relations or ways to get higher-order coefficients), but i discovered a way to get the same without pow-based equations... i compared things and found the same results:
https://cycling74.com/forums/-sharing-corrupts-the-youths-get-the-kids-hooked-on-acid-starter-patch

if you need more polynomials, though, i found many more than were listed on wikipedia, here's a few of the first kind:
T1(x) = x
T2(x) = 2x^2 - 1
T3(x) = 4x^3 - 3x
T4(x) = 8x^4 - 8x^2 + 1
T5(x) = 16x^5 - 20x^3 + 5x
T6(x) = 32x^6 - 48x^4 + 18x^2 - 1
T7(x) = 64x^7 - 112x^5 + 56x^3 - 7x
T8(x) = 128x^8 - 256x^6 + 160x^4 - 32x^2 + 1
T9(x) = 256x^9 - 576x^7 + 432x^5 - 120x^3 + 9x
T10(x) = 512x^10 - 1280x^8 + 1120x^6 - 400x^4 + 50x^2 - 1
T11(x) = 1024x^11 - 2816x^9 + 2816x^7 - 1232x^5 + 220x^3 - 11x
T12(x) = 2048x^12 - 6144x^10 + 6912x^8 - 3584x^6 + 840x^4 - 72x^2 + 1
T13(x) = 4096x^13 - 13312x^11 + 16640x^9 - 9984x^7 + 2912x^5 - 364x^3 + 13x
T14(x) = 8192x^14 - 28672x^12 + 39424x^10 - 26880x^8 + 9408x^6 - 1568x^4 + 98x^2 - 1
T15(x) = 16384x^15 - 61440x^13 + 92160x^11 - 70400x^9 + 28800x^7 - 6048x^5 + 560x^3 - 15x

and here's ones of the second kind:

U1(x) = 2x
U2(x) = 4x^2 - 1
U3(x) = 8x^3 - 4x
U4(x) = 16x^4 - 12x^2 + 1
U5(x) = 32x^5 - 32x^3 + 6x
U6(x) = 64x^6 - 80x^4 + 24x^2 - 1
U7(x) = 128x^7 - 192x^5 + 80x^3 - 8x
U8(x) = 256x^8 - 448x^6 + 240x^4 - 40x^2 + 1
U9(x) = 512x^9 - 1024x^7 + 672x^5 - 160x^3 + 10x
U10(x) = 1024x^10 - 2304x^8 + 1792x^6 - 560x^4 + 60x^2 - 1
U11(x) = 2048x^11 - 5120x^9 + 4608x^7 - 1792x^5 + 280x^3 - 12x
U12(x) = 4096x^12 - 11264x^10 + 11520x^8 - 5376x^6 + 1120x^4 - 84x^2 + 1

and i coded a signal ipow~ external using this code and tried it out, so these equations don't need to be so expensive as using the regular pow~:
https://gist.github.com/orlp/3551590
(they should add bitwise ops to gen~, then we can use code like that anywhere)
but i think i might keep experimenting with the other way i mention in that newer thread as it doesn't seem too expensive, either.

and just for the archive, this patch was the end result of what i was playing with in this thread to research:

Max Patch
Copy patch and select New From Clipboard in Max.

anyways, Thanks again, Volker!

volker böhm's icon

>> i never understood what is the rule

I'm not sure i understand either 😂, i couldn't find any easy 'causal' relations or ways to get higher-order coefficients

next to what you found out in the other thread (bravo, sounds cool by the way!) there is a simple recursive equation:
T[n+1](x) = 2xT[n](x) - T[n-1](x),
where T[0](x) = 1 and T[1](x) = x

👽'tW∆s ∆lienz👽's icon

T[n+1](x) = 2xT[n](x) - T[n-1](x),
where T[0](x) = 1 and T[1](x) = x

Thank you again, Volker... focusing on the above has gotten me one step closer(when i first saw it, i thought i didn't understand because T[n](x) and T[n-1](x) didn't seem to have any common powers/exponents so i had no idea how i would subtract them, but then I realize now: "2x * T[n](x)" is crucial to creating an equation which would have powers in common ...i had looked passed the equation too fast to notice that before).... however, when i tried to work out the 16th order, i still can't quite seem to get it, here's my attempted proof with a patch below which shows i'm making some mistake i don't grasp yet:

example to find T16(x) take
T15(x) = 16384x^15 - 61440x^13 + 92160x^11 - 70400x^9 + 28800x^7 - 6048x^5 + 560x^3 - 15x;
and
T14(x) = 8192x^14 - 28672x^12 + 39424x^10 - 26880x^8 + 9408x^6 - 1568x^4 + 98x^2 - 1

for T16(x), would be:
2x * (16384x^15 - 61440x^13 + 92160x^11 - 70400x^9 + 28800x^7 - 6048x^5 + 560x^3 - 15x)
- 
(8192x^14 - 28672x^12 + 39424x^10 - 26880x^8 + 9408x^6 - 1568x^4 + 98x^2 - 1);

there are no powers in common at first, but 2x*T[n](x) is key to creating powers in common so:
2x * 
(16384x^15 - 61440x^13 + 92160x^11 - 70400x^9 + 28800x^7 - 6048x^5 + 560x^3 - 15x) 
= 
32768x^16 - 122880x^14 + 184320x^12 - 140800x^10 + 57600x^8 - 12096x^6 + 1120x^4 - 30x^2
 
now we can subtract more easily since there will be powers in common:

(32768x^16 - 122880x^14 + 184320x^12 - 140800x^10 + 57600x^8 - 12096x^6 + 1120x^4 - 30x^2)
                -
(8192x^14 - 28672x^12 + 39424x^10 - 26880x^8 + 9408x^6 - 1568x^4 + 98x^2 - 1)
              
= (being careful of the sign that comes before coefficients in the T[n-1](x) equation)...

32768x^16 - (122880 - 8192)x^14 + (184320 - -28672)x^12 - (140800 - 39424)x^10 + (57600 - -26880)x^8 - (12096 - 9408)x^6 + (1120 - -1568)x^4 - (30 - 98)x^2 - (-1)
=
32768x^16 - 114688x^14 + 212992x^12 - 101376x^10 + 84480x^8 - 2688x^6 + 2688x^4 - (-68)x^2 - (-1)
=
32768x^16 - 114688x^14 + 212992x^12 - 101376x^10 + 84480x^8 - 2688x^6 + 2688x^4 + 68x^2 + 1
Max Patch
Copy patch and select New From Clipboard in Max.

i'll keep working on this but if anyone finds the mistake, i'd love to know(it must be something simple, like a reversed sign, or something to do with the way i subtracted the two equations)...

👽'tW∆s ∆lienz👽's icon

ha, ...and now i realize i am not actually being careful of the sign... ok, i've almost got it...
nobody move! i need the earth to remain completely still for me to figure this out 😜.... working... working...

👽'tW∆s ∆lienz👽's icon

i did it! 🙌 (apparently i had forgotten my high-school math and was inventing my own math to relate signs being subtracted from each other....you can all resume your activities now 😋)

given: T[n+1](x) = 2xT[n](x) - T[n-1](x)
here's an example to find T[16](x) -
taking the following previous two orders:
T15(x) = 16384x^15 - 61440x^13 + 92160x^11 - 70400x^9 + 28800x^7 - 6048x^5 + 560x^3 - 15x;
and
T14(x) = 8192x^14 - 28672x^12 + 39424x^10 - 26880x^8 + 9408x^6 - 1568x^4 + 98x^2 - 1....

for T[16](x), would be:
2x *
(16384x^15 - 61440x^13 + 92160x^11 - 70400x^9 + 28800x^7 - 6048x^5 + 560x^3 - 15x)
-
(8192x^14 - 28672x^12 + 39424x^10 - 26880x^8 + 9408x^6 - 1568x^4 + 98x^2 - 1);

there are no powers in common at first, but 2x*T[n](x) is key to creating powers in common so:
2x * (16384x^15 - 61440x^13 + 92160x^11 - 70400x^9 + 28800x^7 - 6048x^5 + 560x^3 - 15x)
=
32768x^16 - 122880x^14 + 184320x^12 - 140800x^10 + 57600x^8 - 12096x^6 + 1120x^4 - 30x^2

now we can subtract more easily since there will be powers in common:
(32768x^16 - 122880x^14 + 184320x^12 - 140800x^10 + 57600x^8 - 12096x^6 + 1120x^4 - 30x^2)
-
(8192x^14 - 28672x^12 + 39424x^10 - 26880x^8 + 9408x^6 - 1568x^4 + 98x^2 - 1)

= (being careful of the sign that comes before coefficients in the T[n-1](x) equation... for real this time 😅)...
32768x^16 - 131072x^14 + 212992x^12 - 180224x^10 + 84480x^8 - 21504x^6 + 2688x^4 - 128x^2 + 1

proven by this patch:

Max Patch
Copy patch and select New From Clipboard in Max.

Thank You, Volker, Much Appreciated!
🍻🍻🍻🍻

Roman Thilenius's icon


as as it seems it is always alternately + and - ?

however, 16384x^15... that is what i always wanted to calculate in a realtime sequencer enviroment - or in a simple audio effect as signal process. pfffffft.

👽'tW∆s ∆lienz👽's icon

always alternately + and - ?

indeed, feels like Chebyshev dancing a very graceful math around my head(not just in a single polynomial, but also over the even ordered ones, they end alternately in +1/-1(?)).. and everything keeps nicely within a manageable range... and the relationship between polynomials of the first kind and second kind is a beauty i'm particularly enjoying:

and here with many harmonics/orders at once, applied... 'radially'(my term):

sacred geometry

like what an astronaut might feel, staring into the infinite darkness beyond an event horizon, without full intellectual comprehension of the math that went into the design of the universe, but it still brings tears to the eyes, being that much closer to the sense of magic behind it all 😭🙏🙌

Roman Thilenius's icon


i love this phaenomen that when you look at the first 3, you are unable to make up a rule how to continue, but if you are given 6 or 7, you can.