So i have this code in MatLab(below). The code looks at the linear function f(x)=ax+b, where b=asin(0.376),and a=2*PI, with the purpose of finding values of x such that f(x) is “close” to being an integer. The code does so in the following manner: First we define an error E=0.1, and then we find the least nonnegative integer x such that the positive distance between f(x) and the integer closest to f(x) is less than E. We call this uniqe x for X_1. (X subscript 1).
Now, we repeat the process with E=0.01, and call the result X_2. Then we repeat with E=0.001,etc… and do this all the way until and including E=10^(-10).
However,there is a problem. When my code finds the least nonnegative integer X for which |round(f(x)) – f(x)|<E, I have made it so that the code also prints out the actual error in the estimate: ActualError= |round(f(X))-f(X)|. Whenever the error is positive and less than 10^(-7), MatLab tells me that the ActualError=0; (Try running the code, and read the three last lines of output). This is not correct, and I wonder if the problem can be avoided by increasing the precision with the digits(n) and vpa() commands. Anything else i should change? 🙂 Thanx
A=asin(0.376); best=10; itr=1; for t=1:10 %Iterates trough the powers 10^-t while best>10^(-t) if abs(round(A+2*pi*itr)-(A+2*pi*itr))< best best=abs(round(A+2*pi*itr)-(A+2*pi*itr)); end itr=itr+1; end fprintf('It is sufficient with %d iterations to get an error that is less',itr); fprintf(' than 10^(-%d).The error is then=%.32f\n',t,best); if t~=10 itr=1; best=10; end end
PS: The function f(x) i mentioned above can get arbitrarily close to having integer value as a result from the fact that the set of numbers on the form sin(N), where N is an integer is dense in [-1,1].
✓ Extra quality
ExtraProxies brings the best proxy quality for you with our private and reliable proxies
✓ Extra anonymity
Top level of anonymity and 100% safe proxies – this is what you get with every proxy package
✓ Extra speed
1,ooo mb/s proxy servers speed – we are way better than others – just enjoy our proxies!
USA proxy location
We offer premium quality USA private proxies – the most essential proxies you can ever want from USA
Our proxies have TOP level of anonymity + Elite quality, so you are always safe and secure with your proxies
Use your proxies as much as you want – we have no limits for data transfer and bandwidth, unlimited usage!
Superb fast proxy servers with 1,000 mb/s speed – sit back and enjoy your lightning fast private proxies!
99,9% servers uptime
Alive and working proxies all the time – we are taking care of our servers so you can use them without any problems
No usage restrictions
You have freedom to use your proxies with every software, browser or website you want without restrictions
Perfect for SEO
We are 100% friendly with all SEO tasks as well as internet marketing – feel the power with our proxies
Buy more proxies and get better price – we offer various proxy packages with great deals and discounts
We are working 24/7 to bring the best proxy experience for you – we are glad to help and assist you!