---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- The compute of limits of a function (and order of infinite/infinitesimal) g(x) -> L as x -> p # # sin(sin(x))/(7*sin(x)+sin(x)^3) as x -> 0 g = function(x) sin(sin(x))/(7*sin(x)+sin(x)^3) BF=4; HF=3; graph2F(g, -pi,pi, "brown") g(0) # NaN point0(0,g(1e-10),"black") # x -> 0+ a 0 da destra for(x in 10^-(2:8) ) more(g(x)) # 0.142852721310892 # 0.142857098639478 # 0.142857142414966 # 0.142857142852721 # 0.142857142857099 # 0.142857142857142 # 0.142857142857143 # A more sophisticated way (also to evaluate variations) A=1;B=10; L=0;for(n in A:B) {x=10^-n; cat(n,'\t'); cat(g(x)-L,'\t'); L=g(x); more(L) } # 1 0.1424172 [1] 0.142417182596157 # 2 0.0004355387 [1] 0.142852721310892 # 3 4.377329e-06 [1] 0.142857098639478 # 4 4.377549e-08 [1] 0.142857142414966 # 5 4.377551e-10 [1] 0.142857142852721 # 6 4.377554e-12 [1] 0.142857142857099 # 7 4.377054e-14 [1] 0.142857142857142 # 8 4.440892e-16 [1] 0.142857142857143 # 9 0 [1] 0.142857142857143 # 10 0 [1] 0.142857142857143 # n g(x)-L L # L is about 0.142857142857143. It is rational? fraction( g(10^-8) ) # 1/7 # x -> 0- a 0 da sinistra fraction( g(-(10^-8)) ) # 1/7 # # With which order g tends to 1/7? x is divided by 10 -> g(x)-L is divided by 100 # g(x)-L is an infinitesimal of order 2 # -------------------- # If I want, I can approximate g near 0 (I compute the ratio between ...) L = 1/7 A=1;B=8; L0=0;for(n in A:B) {x=10^-n; U=(L-g(x))/x^2; cat(n,'\t',U-L0,'\t'); more(U); L0=U} # 1 0.04399603 [1] 0.0439960260985861 # 2 0.0002194364 [1] 0.0442154625035496 # 3 2.202332e-06 [1] 0.0442176648352 (/100) # 4 2.023381e-08 [1] 0.0442176850690146 there is no longer a regular approach # 5 -6.938894e-18 [1] 0.0442176850690146 # 6 -3.053113e-06 [1] 0.0442146319556969 # 7 0.000194289 [1] 0.0444089209850063 # 8 -0.04440892 [1] 0 # n variation (L-g(x))/x^2 h = function(x) 1/7 - 0.0442177*x^2 # as x -> 0 g(x) ~ h(x) graph1(h, -pi,pi, "blue") # If I want a more accurate valutation I can use 2^-n instead of 10^-n A=9;B=15; L0=0;for(n in A:B) {x=2^-n; U=(L-g(x))/x^2; cat(n,'\t',U-L0,'\t'); more(U); L0=U} # 9 0.0442176 [1] 0.0442176022042986 # 10 6.365008e-08 [1] 0.0442176658543758 # 11 1.589069e-08 [1] 0.0442176817450672 (/4) # 12 3.958121e-09 [1] 0.0442176857031882 # 13 1.396984e-09 [1] 0.044217687100172 there is no longer a regular approach # 14 -3.72529e-09 [1] 0.0442176833748817 # 15 -7.450581e-09 [1] 0.0442176759243011 # 0.044217687 # -------------------- # g(x) -> L as x -> ∞ # # (1+1/x)^x as x -> ∞ g = function(x) (1+1/x)^x BF=4; HF=3; Plane(0,50, 0,3); graph2(g, 0,50, "brown") # I prove with 10^n: A=1;B=12; L=0;for(n in A:B) {x=10^n; cat(n,'\t'); cat(g(x)-L,'\t'); L=g(x); more(L) } # 1 2.593742 [1] 2.5937424601 # 2 0.1110714 [1] 2.70481382942153 # 3 0.0121101 [1] 2.71692393223559 # 4 0.001221995 [1] 2.71814592682493 (/10) # 5 0.0001223104 [1] 2.7182682371923 # 6 1.22319e-05 [1] 2.71828046909573 # 7 1.225037e-06 [1] 2.71828169413255 # 8 1.042066e-07 [1] 2.71828179833913 there is no longer a regular approach # 9 2.536574e-07 [1] 2.71828205199649 # 10 1.238298e-09 [1] 2.71828205323479 # 11 1.223226e-10 [1] 2.71828205335711 # 12 0.0002414427 [1] 2.71852349603724 # # If I want a more accurate valutation I can use 2^-n instead of 10^-n A=30;B=32; L=0;for(n in A:B) {x=2^n; cat(n,'\t'); cat(g(x)-L,'\t'); L=g(x); more(L) } # 30 2.718282 [1] 2.71828182719316 # 31 6.329839e-10 [1] 2.71828182782615 # 32 3.164495e-10 [1] 2.7182818281426 (/2) A=40;B=42; L=0;for(n in A:B) {x=2^n; cat(n,'\t'); cat(g(x)-L,'\t'); L=g(x); more(L) } # 40 2.718282 [1] 2.71828182845781 # 41 6.181722e-13 [1] 2.71828182845843 # 42 3.08642e-13 [1] 2.71828182845874 A=50;B=52; L=0;for(n in A:B) {x=2^n; cat(n,'\t'); cat(g(x)-L,'\t'); L=g(x); more(L) } # 50 2.718282 [1] 2.71828182845904 # 51 4.440892e-16 [1] 2.71828182845904 there is no longer a regular approach # 52 4.440892e-16 [1] 2.71828182845905 # I deepen the situation A=48;B=52; L=0;for(n in A:B) {x=2^n; cat(n,'\t'); cat(g(x)-L,'\t'); L=g(x); more(L) } # 48 2.718282 [1] 2.71828182845904 # 49 2.664535e-15 [1] 2.71828182845904 # 50 1.332268e-15 [1] 2.71828182845904 # 51 4.440892e-16 [1] 2.71828182845904 # 52 4.440892e-16 [1] 2.71828182845905 # 2.71828182845905 # I can find that this nummber is Napier's constant (or Euler's number) e, exp(1) more(exp(1)) # 2.71828182845905 # L = exp(1) # With which order g tends to L? x is multiplied by 2 -> g(x)-L is divided by 2 # g(x)-L is an infinitesimal of order 1 (respect to 1/x) # # -------------------- # If I want, I can approximate g(x) as x -> ∞ (I compute the ratio between ...) A=20;B=23; L0=0;for(n in A:B) {x=2^n; U=(L-g(x))/(1/x); cat(n,'\t',U-L0,'\t'); more(U); L0=U} # 20 1.35914 [1] 1.3591397292912 # 21 6.016344e-07 [1] 1.35914033092558 # 22 -3.613532e-07 [1] 1.35913996957242 # 23 4.824251e-07 [1] 1.35914045199752 A=18;B=23; L0=0;for(n in A:B) {x=2^n; U=(L-g(x))/(1/x); cat(n,'\t',U-L0,'\t'); more(U); L0=U} # 18 1.359136 [1] 1.35913616209291 # 19 2.376735e-06 [1] 1.35913853882812 # 20 1.190463e-06 [1] 1.3591397292912 (/2) # 21 6.016344e-07 [1] 1.35914033092558 # 22 -3.613532e-07 [1] 1.35913996957242 there is no longer a regular approach # 23 4.824251e-07 [1] 1.35914045199752 # h = function(x) exp(1) - 1.35914/x # as x -> ∞ g(x) ~ h(x) graph1(h, 0,50, "red") # -------------------- # g(x) -> ∞ as x -> ∞ # # sqrt(x^5)*sin(5/x^2) as x -> ∞ g = function(x) sqrt(x^5)*sin(5/x^2) graph2F(g, 0,3, "brown") graph2F(g, 0,15, "brown") # It's clear the limit of g as x -> ∞ is ∞. We find the order of infinite. for(x in 10^(4:10) ) more(g(x)) # 500 # 1581.13883008419 # 5000 # 15811.3883008419 # 50000 # 158113.883008419 # 5e+05 # If I multiply the input by 100 the output multiplies by 10: # as x -> ∞ g(x) is an infinite of order 1/2 # # -------------------- # If I want, I can approximate g(x) as x ->∞ (I compute the ratio between ...) A=5;B=15; L0=0;for(n in A:B) {x=2^n; U=g(x)/sqrt(x); cat(n,'\t',U-L0,'\t'); more(U); L0=U } # 5 4.99998 [1] 4.99998013180876 # 6 1.862643e-05 [1] 4.99999875823666 # 7 1.164153e-06 [1] 4.99999992238979 # 8 7.275958e-08 [1] 4.99999999514936 # 9 4.547474e-09 [1] 4.99999999969684 # 10 2.842171e-10 [1] 4.99999999998105 # 11 1.776357e-11 [1] 4.99999999999882 # 12 1.110223e-12 [1] 4.99999999999993 # 13 6.927792e-14 [1] 5 # 14 4.440892e-15 [1] 5 # 15 0 [1] 5 # The ratio is 5. Then: as x -> ∞ g(x) ~ 5*sqrt(x) h = function(x) 5*sqrt(x) graph2F(g, 0,15, "brown") graph1(h, 0,15, "seagreen") # -------------------- # Other examples # # (cos(x)-1)/x^2 as x -> 0 g = function(x) (cos(x)-1)/x^2 graph2F(g, -4*pi,4*pi, "brown") pointO(0,-1/2, "blue") # x -> 0+ for(x in 10^-(2:8) ) more(g(x)) # -0.499995833347366 # -0.499999958325503 # -0.499999996961265 # -0.500000041370185 # -0.500044450291171 # -0.49960036108132 # 0 # It is best to approach 0 more slowly (and to evaluate variations) A=7;B=14; L=0;for(n in A:B) {x=2^-n; cat(n,'\t'); cat(g(x)-L,'\t'); L=g(x); more(L) } # 7 -0.4999975 [1] -0.499997456874553 # 8 -1.907345e-06 [1] -0.499999364219548 # 9 -4.768444e-07 [1] -0.499999841063982 # 10 -1.192384e-07 [1] -0.499999960302375 (/4) # 11 -2.991874e-08 [1] -0.499999990221113 # 12 -7.916242e-09 [1] -0.499999998137355 # 13 -1.862645e-09 [1] -0.5 # 14 0 [1] -0.5 # -1/2 # x -> 0- g(2^-13) # -1/2 L = -1/2 # With which order g tends to -1/2? # As I divide by 2 the distance from 0 the distance of g(x) from the limit L is # divided by 4: g(x)-L is an infinitesimal of order 2 # # -------------------- # # If I want, I can approximate g near 0 (I compute the ratio between ...) A=4;B=12; L0=0;for(n in A:B) {x=2^-n; U=(g(x)-L)/x^2; cat(n,'\t',U-L0,'\t'); more(U); L0=U } # 4 0.04166124 [1] 0.0416612416956923 # 5 4.068694e-06 [1] 0.0416653103893623 # 6 1.016655e-06 [1] 0.0416663270443678 (/4) # 7 2.402812e-07 [1] 0.041666567325592 # 8 -5.960464e-08 [1] 0.0416665077209473 there is no longer a regular approach # 9 -2.384186e-06 [1] 0.0416641235351562 # 10 -3.814697e-05 [1] 0.0416259765625 # 11 -0.0006103516 [1] 0.041015625 # 12 -0.009765625 [1] 0.03125 fraction(0.0416666) # 1/24 h = function(x) 1/24*x^2-1/2; graph1(h, -4*pi,4*pi, "seagreen") # as x -> 0 g(x) ~ h(x) # -------------------- # # (x-1)^2+(1-x)^3+sqrt(x^2-1) as x -> 1 g = function(x) (x-1)^2+(1-x)^3+sqrt(x^2-1) graph2F(g, -2,4, "brown") # It's clear the limit as x -> 1+ is 0. With which order g tends to 0? A=2;B=8; L=0;for(n in A:B) {x=(1+10^-n); cat(n,'\t'); cat(g(x)-L,'\t'); L=g(x); more(L) } # 2 0.1418735 [1] 0.141873468787578 # 3 -0.09713993 [1] 0.0447335374926867 # 4 -0.03059104 [1] 0.0141424991716993 # 5 -0.009670352 [1] 0.00447214723534007 # 6 -0.003057933 [1] 0.0014142139168997 # 7 -0.0009670003 [1] 0.000447213606811918 # 8 -0.0003057923 [1] 0.000141421355807667 # As I divide by 100 the distance from 1 the distance of g(x) from 0 is divided by 10: # as x -> 1+ g(x) is an infinitesimal of order 1/2 # # -------------------- # If I want, I can approximate g near 0 (I compute the ratio between ...) A=5;B=13; L0=0;for(n in A:B) {x=1+10^-n; U=g(x)/(x-1)^(1/2); cat(n,'\t',U-L0,'\t'); more(U); L0=U } # 5 1.414217 [1] 1.41421712952533 # 6 -3.212567e-06 [1] 1.41421391695787 # 7 -3.192261e-07 [1] 1.4142135977318 # 8 -3.53577e-08 [1] 1.4142135623741 # 9 -9.681145e-13 [1] 1.41421356237313 # 10 -3.08642e-14 [1] 1.4142135623731 # 11 -1.110223e-15 [1] 1.41421356237309 # 12 2.220446e-16 [1] 1.4142135623731 # 13 -2.220446e-16 [1] 1.41421356237309 more(sqrt(2)) # 1.4142135623731 # The ratio is sqrt(2). Then: as x -> 1+ g(x) ~ sqrt(2)*sqrt(x-1) h = function(x) sqrt(2)*sqrt(x-1) graph2F(g, 1,3, "brown"); graph1(h, 1,4, "seagreen") # -------------------- # # (1+1/x)^sqrt(x) as x -> ∞ g = function(x) (1+1/x)^sqrt(x) BF=4; HF=3; Plane(0,50, 0,3); graph2(g, 0,50, "brown") A=1;B=12; L=0;for(n in A:B) {x=10^n; cat(n,'\t'); cat(g(x)-L,'\t'); L=g(x); more(L) } 1 1.351746 [1] 1.35174621929824 2 -0.2471241 [1] 1.1046221254112 3 -0.07251034 [1] 1.03211178061832 4 -0.02206212 [1] 1.01004966209288 5 -0.006882395 [1] 1.00316726707346 6 -0.002166767 [1] 1.00100049966613 7 -0.0006842219 [1] 1.00031627775566 8 -0.0002162728 [1] 1.00010000499906 9 -6.838172e-05 [1] 1.00003162327921 10 -2.162323e-05 [1] 1.00001000005083 11 -6.837768e-06 [1] 1.00000316228292 12 -2.162194e-06 [1] 1.0000010000894 # # If I want a more accurate valutation I can use 2^-n instead of 10^-n A=45;B=55; L=0;for(n in A:B) {x=2^n; cat(n,'\t'); cat(g(x)-L,'\t'); L=g(x); more(L) } # 45 1 [1] 1.00000016858741 # 46 -4.937811e-08 [1] 1.0000001192093 # 47 -3.49156e-08 [1] 1.0000000842937 # 48 -2.468905e-08 [1] 1.00000005960465 # 49 -1.74578e-08 [1] 1.00000004214685 # 50 -1.234453e-08 [1] 1.00000002980232 # 51 -8.728898e-09 [1] 1.00000002107342 # 52 -6.172263e-09 [1] 1.00000001490116 # 53 -1.490116e-08 [1] 1 # 54 0 [1] 1 # 55 0 [1] 1 L = 1 # With which order g tends to L? x is multiplied by 2 -> g(x)-L is divided by √2: 4.937811/3.49156 # 1.414213 3.49156/2.468905 # 1.414214 sqrt(2) # 1.414214 # As x -> ∞ g(x)-1 ~ K*1/sqrt(x). # # -------------------- K = ? A=40;B=43; L0=0;for(n in A:B) {x=2^n; U=(1-g(x))/(1/sqrt(x)); cat(n,'\t',U-L0,'\t'); more(U); L0=U} # 40 -1 [1] -1.00000047660433 # 41 1.394217e-07 [1] -1.00000033718267 # 42 9.87641e-08 [1] -1.00000023841858 # 43 6.98233e-08 [1] -1.00000016859528 # K = 1 h = function(x) 1+1/sqrt(x) graph2(h, 0,50, "seagreen") # -------------------- Other examples of use