problem in iteration code
显示 更早的评论
please refer my last comment before start working on this code
i have to find the value of y(i) till y(i)-y(i-1)<=2.59e-4
can anyone help me with the code first correcting the error then how can i again start the iteration if y(i)-y(i-1)=>2.59e-4
necessary file is attached with question
回答(1 个)
Walter Roberson
2017-2-9
1 个投票
By the point of vpaQ(3), your expression is so unstable that if you calculate the expression in floating point, then the difference in values between adjacent representable double precision numbers can on order of 10^33.
I will see if I can figure out what resolution would be required for reasonable operation.
8 个评论
NILESH PANDEY
2017-2-9
编辑:NILESH PANDEY
2017-2-9
NILESH PANDEY
2017-2-9
编辑:Walter Roberson
2017-2-9
NILESH PANDEY
2017-2-10
编辑:NILESH PANDEY
2017-2-10
Walter Roberson
2017-2-10
... I am not ignoring you ;-)
I have not had a chance to work with your latest version. The version before had the same kinds of problems as earlier. Your internal frequency was about 2E-8 according to some tests I did (that is, x + 1E-8 would be half a phase away from x), but when I looked at it mathematically it appeared that the frequency should be even higher than that. Even with n = 6, you were not getting convergence at all; you were getting divergence for sure, according to my tests. As such it is pointless to define convergence as minima less than 1E-4 apart, as that is at least 5000 cycles with some major value differences over that range.
I have been trying to see if I can come up with a usable hypothesis of how far apart the extremest minima are for a sum of sin with rational (but non-integer) multiples of pi. The sign of the terms matter, but the location of the extremest minima (where all of the cycles negatively reinforce each other) does not appear to depend upon the multiplier of the sin terms otherwise. The idea is that since you know all of the fractions that are going into the sin(Fraction*pi*x) terms, that it ought to be possible to predict the x at which there is the greatest minima... or at least to figure out what the period is.
Anyhow, it is taking a while, but at least up to before your most recent version (which I haven't read) your approach was not working.
NILESH PANDEY
2017-2-10
Walter Roberson
2017-2-11
Your vpay(6) has a frequency between 2E-8 to 4E-8 (it is higher frequency right near 0.)
Your vpay(2), vpay(4), and vpay(6) have greatly increasing oscillations towards the right end of the range. The greatest minima for them is within a relatively small number of cycles of the right end of whatever range you are using.
Yes, you could find the absolute minimum value over any given range, but not in any useful form.
The more terms you add, the greater the oscillations.
The formula being produced by your code are diverging, not converging, over the range you calculate.
Note: sometimes there are formula that have larger and larger values for the first few hundred terms, but which converge after that, so I cannot say at the moment that your formula is definitely wrong.
I can say, though, that if you were to try to calculate your values numerically instead of with the symbolic toolbox, that round off error would lead to garbage results.
NILESH PANDEY
2017-2-11
NILESH PANDEY
2017-2-12
编辑:NILESH PANDEY
2017-2-13
类别
在 帮助中心 和 File Exchange 中查找有关 Choose a Solver 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!