problem in iteration code
Mostrar comentarios más antiguos
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 comentario
KSSV
el 8 de Feb. de 2017
Your code shows error....please rectify it.
Respuestas (1)
Walter Roberson
el 9 de Feb. de 2017
1 voto
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 comentarios
NILESH PANDEY
el 9 de Feb. de 2017
Editada: NILESH PANDEY
el 9 de Feb. de 2017
NILESH PANDEY
el 9 de Feb. de 2017
Editada: Walter Roberson
el 9 de Feb. de 2017
NILESH PANDEY
el 10 de Feb. de 2017
Editada: NILESH PANDEY
el 10 de Feb. de 2017
Walter Roberson
el 10 de Feb. de 2017
... 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
el 10 de Feb. de 2017
Walter Roberson
el 11 de Feb. de 2017
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
el 11 de Feb. de 2017
NILESH PANDEY
el 12 de Feb. de 2017
Editada: NILESH PANDEY
el 13 de Feb. de 2017
Categorías
Más información sobre Choose a Solver en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!