Author Topic: Removable singularity  (Read 4167 times)

0 Members and 1 Guest are viewing this topic.

Offline _vince

  • Seasoned Forum Regular
  • Posts: 422
    • View Profile
Removable singularity
« on: January 13, 2022, 05:23:42 am »
what happens when you take a function f(x), multiply it by (x-1) then divide by (x-1)? Would it be infinity at x=1? 

g(x) = f(x)*(x-1)/(x-1).  what is g(1)?

Try it out with the mouse:

Code: QB64: [Select]
  1. const sw = 800
  2. const sh = 600
  3.  
  4. pi = 4*atn(1)
  5.  
  6. screen _newimage(sw, sh, 32)
  7.  
  8.         do
  9.                 mx = _mousex
  10.                 my = _mousey
  11.                 mbl = _mousebutton(1)
  12.                 mbr = _mousebutton(2)
  13.                 mw = mw + _mousewheel
  14.         loop while _mouseinput
  15.  
  16.         for yy=0 to sh
  17.         for xx=0 to sw
  18.                         u = (xx - sw/2)*0.01
  19.                         v = (sh/2 - yy)*0.01
  20.  
  21.  
  22.                         cmul uu, vv, u - (mx - sw/2)*0.01, v - (sh/2 - my)*0.01, u + 0.707, v - 0.707
  23.                         cdiv x, y, uu, vv, u - 1, v
  24.  
  25.  
  26.                 m = sqr(x*x + y*y)
  27.                 a = (pi + _atan2(y, x))/(2*pi)
  28.  
  29.                 pset (xx, yy), hrgb&(a, m)
  30.  
  31.         next
  32.         next
  33.  
  34.         _display
  35.         _limit 60
  36.  
  37.  
  38.  
  39. function hrgb&(h, m)
  40.         r =  0.5 - 0.5*sin(2*pi*h - pi/2)
  41.     g = (0.5 + 0.5*sin(2*pi*h*1.5 - pi/2)) * -(h < 0.66)
  42.     b = (0.5 + 0.5*sin(2*pi*h*1.5 + pi/2)) * -(h > 0.33)
  43.  
  44.         dim n as long
  45.     n = 16
  46.    
  47.     mm = m*500 mod 500
  48.         p = abs((h*n) - int(h*n))
  49.  
  50.         rr = 255*r - 0.15*mm - 35*p
  51.         gg = 255*g - 0.15*mm - 35*p
  52.         bb = 255*b - 0.15*mm - 35*p
  53.  
  54.         if rr < 0 then rr = 0
  55.         if gg < 0 then gg = 0
  56.         if bb < 0 then bb = 0
  57.  
  58.         hrgb& = _rgb(rr, gg, bb)
  59.  
  60.  
  61. 'u + iv = (x + iy)*(a + ib)
  62. sub cmul(u, v, xx, yy, aa, bb)
  63.         x = xx
  64.         y = yy
  65.         a = aa
  66.         b = bb
  67.  
  68.     u = x*a - y*b
  69.     v = x*b + y*a
  70.  
  71. 'u + iv = (x + iy)/(a + ib)
  72. sub cdiv(u, v, xx, yy, aa, bb)
  73.         x = xx
  74.         y = yy
  75.         a = aa
  76.         b = bb
  77.  
  78.     d = a*a + b*b
  79.     u = (x*a + y*b)/d
  80.     v = (y*a - x*b)/d
  81.  

a singularity and two zeros
 
sngthere.png


singularity removed with the mouse
 
sngremoved.png
« Last Edit: January 13, 2022, 05:50:32 am by _vince »

Offline _vince

  • Seasoned Forum Regular
  • Posts: 422
    • View Profile
Re: Removable singularity
« Reply #1 on: January 13, 2022, 06:10:29 am »
Same thing but for the mighty

sin(x + iy)/(x + iy - mousex - imousey)

Code: QB64: [Select]
  1. const sw = 800
  2. const sh = 600
  3.  
  4. pi = 4*atn(1)
  5.  
  6. screen _newimage(sw, sh, 32)
  7.  
  8.  
  9. zz = 0.02
  10.  
  11.         do
  12.                 mx = _mousex
  13.                 my = _mousey
  14.                 mbl = _mousebutton(1)
  15.                 mbr = _mousebutton(2)
  16.                 mw = mw + _mousewheel
  17.         loop while _mouseinput
  18.  
  19.         for yy=0 to sh
  20.         for xx=0 to sw
  21.                         u = (xx - sw/2)*zz
  22.                         v = (sh/2 - yy)*zz
  23.  
  24.  
  25.                         'cmul uu, vv, u - (mx - sw/2)*0.01, v - (sh/2 - my)*0.01, u + 0.707, v - 0.707
  26.                         'cdiv x, y, uu, vv, u - 1, v
  27.  
  28.                         sinz uu, vv, u, v
  29.                         cdiv x, y, uu, vv, u - (mx - sw/2)*zz, v - (sh/2 - my)*zz
  30.  
  31.                 m = sqr(x*x + y*y)
  32.                 a = (pi + _atan2(y, x))/(2*pi)
  33.  
  34.                 'pset (xx, yy), hrgb&(a, m)
  35.                 pset (xx, yy), hrgb&(a, log(5000*m + 1))
  36.  
  37.         next
  38.         next
  39.  
  40.         _display
  41.         _limit 60
  42.  
  43.  
  44.  
  45. function hrgb&(h, m)
  46.         r =  0.5 - 0.5*sin(2*pi*h - pi/2)
  47.     g = (0.5 + 0.5*sin(2*pi*h*1.5 - pi/2)) * -(h < 0.66)
  48.     b = (0.5 + 0.5*sin(2*pi*h*1.5 + pi/2)) * -(h > 0.33)
  49.  
  50.         dim n as long
  51.     n = 16
  52.    
  53.     mm = m*500 mod 500
  54.         p = abs((h*n) - int(h*n))
  55.  
  56.         rr = 255*r - 0.15*mm - 35*p
  57.         gg = 255*g - 0.15*mm - 35*p
  58.         bb = 255*b - 0.15*mm - 35*p
  59.  
  60.         if rr < 0 then rr = 0
  61.         if gg < 0 then gg = 0
  62.         if bb < 0 then bb = 0
  63.  
  64.         hrgb& = _rgb(rr, gg, bb)
  65.  
  66. function cosh(x)
  67.     cosh = 0.5*(exp(x) + exp(-x))
  68.  
  69. function sinh(x)
  70.     sinh = 0.5*(exp(x) - exp(-x))
  71.  
  72. sub sinz(u, v, xx, yy)
  73.         x = xx
  74.         y = yy
  75.         u = sin(x)*cosh(y)
  76.         v = cos(x)*sinh(y)
  77.  
  78. sub cosz(u, v, xx, yy)
  79.         x = xx
  80.         y = yy
  81.         u = cos(x)*cosh(y)
  82.         v =-sin(x)*sinh(y)
  83.  
  84.  
  85. 'u + iv = (x + iy)*(a + ib)
  86. sub cmul(u, v, xx, yy, aa, bb)
  87.         x = xx
  88.         y = yy
  89.         a = aa
  90.         b = bb
  91.  
  92.     u = x*a - y*b
  93.     v = x*b + y*a
  94.  
  95. 'u + iv = (x + iy)/(a + ib)
  96. sub cdiv(u, v, xx, yy, aa, bb)
  97.         x = xx
  98.         y = yy
  99.         a = aa
  100.         b = bb
  101.  
  102.     d = a*a + b*b
  103.     u = (x*a + y*b)/d
  104.     v = (y*a - x*b)/d
  105.  
  106.  
  107.  

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Re: Removable singularity
« Reply #2 on: January 13, 2022, 06:40:42 pm »
I like what you do, you do a very interesting thing.

Offline _vince

  • Seasoned Forum Regular
  • Posts: 422
    • View Profile
Re: Removable singularity
« Reply #3 on: January 14, 2022, 05:04:32 am »
Another note, the plot has two zeros and one pole (or singularity).  Stick it on the pole and it cancels but stick it on the other zero and notice the colours encircling it.  It goes from RGB to RGBRGB as you've increased the order of the zero to say (x-1)^2, a sort of period halving.

If you remember that exp(i w t) = sin wt + i cos wt, then (exp(i w t))^2 = sin 2wt + i cos 2wt, a sort of frequency doubling

 
period2.png