You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
problem in iteration code
1 view (last 30 days)
Show older comments
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
Answers (1)
Walter Roberson
on 9 Feb 2017
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 Comments
NILESH PANDEY
on 9 Feb 2017
Edited: NILESH PANDEY
on 9 Feb 2017
Thank you sir i want to inform you that Q should be in order of 1e34,35..etc because they are the inversion chargers in a semiconductor device and sir i wanna ask one more question using vpa is right ? by means i want to calculate Q and y,firstly Q(1) is given then i calculated y(1) then Q(2) is calculated then again y(2) and so on is this code is going in this way as i described above? if anything other information is required then kindly inform me
note:-sir above mathematics is developed by me so i am using a algorithm which i have developed,some other great scientist also calculated Q and y by other algo they used newton and gummel method for iteration i don't know how to use these i mentioned this because may be this can reduce complexity of calculation and algorithm which i am using is also correct
NILESH PANDEY
on 9 Feb 2017
Edited: Walter Roberson
on 9 Feb 2017
hey i think i got solution of this problem because of limit of matlab display we can reduce the value of n in code what i observe if we keep n=5,6,7 then also the error produce by them as compare to if i keep n=102 is very low because of hyperbolic function they converge very fast so only n=5or7 terms is required for appropriate answer higher terms may be neglect by this all are coming in range
can anyone help me to plot different y(i) because in vpay(i) i got a vector of y(i) which has all y(i) i have to plot last y(i) so how should i get last y(i) and plot this ?
NILESH PANDEY
on 10 Feb 2017
Edited: NILESH PANDEY
on 10 Feb 2017
hi i got the last value of vpa by using vpay(k) where k is whatever value of y i want,i still can't plot this suppose i got vpay(6) as
(3852594936737163*sin((5270717853328913*x)/8388608))/9223372036854775808 - (5720530583262469*sin((3294198658330571*x)/4194304))/2305843009213693952 - (1890191513553995*sin((3953038389996685*x)/8388608))/72057594037927936 - (1239487464334486929408*x)/8079879893910767 + (788820049541845*sin((5270717853328913*x)/16777216))/288230376151711744 - (160878178232529*sin((5270717853328913*x)/33554432))/281474976710656 - ((2927114230116077*sin((3294198658330571*x)/4194304))/1152921504606846976 + (8956713847111951*sin((3953038389996685*x)/8388608))/288230376151711744 + (6532666692102853*sin((5270717853328913*x)/33554432))/9007199254740992)*((1259161868530272436224*x)/283303674451637 + (5720530583262469*sin((3294198658330571*x)/4194304))/79586171463010656 + (1890191513553995*sin((3953038389996685*x)/8388608))/2487067858219083 - (1284198312245721*sin((5270717853328913*x)/8388608))/106114895284014208 - (788820049541845*sin((5270717853328913*x)/16777216))/9948271432876332 + (13728271209175808*sin((5270717853328913*x)/33554432))/829022619406361 + (((2927114230116077*sin((3294198658330571*x)/4194304))/16 + (8956713847111951*sin((3953038389996685*x)/8388608))/4 + 52261333536822824*sin((5270717853328913*x)/33554432))*((1259161868530272436224*x)/283303674451637 + (5720530583262469*sin((3294198658330571*x)/4194304))/79586171463010656 + (1890191513553995*sin((3953038389996685*x)/8388608))/2487067858219083 - (1284198312245721*sin((5270717853328913*x)/8388608))/106114895284014208 - (788820049541845*sin((5270717853328913*x)/16777216))/9948271432876332 + (13728271209175808*sin((5270717853328913*x)/33554432))/829022619406361 + (((2927114230116077*sin((3294198658330571*x)/4194304))/16 + (8956713847111951*sin((3953038389996685*x)/8388608))/4 + 52261333536822824*sin((5270717853328913*x)/33554432))*((1259161868530272436224*x)/283303674451637 + (5720530583262469*sin((3294198658330571*x)/4194304))/79586171463010656 + (1890191513553995*sin((3953038389996685*x)/8388608))/2487067858219083 - (1284198312245721*sin((5270717853328913*x)/8388608))/106114895284014208 - (788820049541845*sin((5270717853328913*x)/16777216))/9948271432876332 + (13728271209175808*sin((5270717853328913*x)/33554432))/829022619406361 + (((2927114230116077*sin((3294198658330571*x)/4194304))/16 + (8956713847111951*sin((3953038389996685*x)/8388608))/4 + 52261333536822824*sin((5270717853328913*x)/33554432))*((1259161868530272436224*x)/283303674451637 + (5720530583262469*sin((3294198658330571*x)/4194304))/79586171463010656 + (1890191513553995*sin((3953038389996685*x)/8388608))/2487067858219083 - (1284198312245721*sin((5270717853328913*x)/8388608))/106114895284014208 - (788820049541845*sin((5270717853328913*x)/16777216))/9948271432876332 + (13728271209175808*sin((5270717853328913*x)/33554432))/829022619406361 + (((2927114230116077*sin((3294198658330571*x)/4194304))/16 + (8956713847111951*sin((3953038389996685*x)/8388608))/4 + 52261333536822824*sin((5270717853328913*x)/33554432))*((1259161868530272436224*x)/283303674451637 + (5720530583262469*sin((3294198658330571*x)/4194304))/79586171463010656 + (1890191513553995*sin((3953038389996685*x)/8388608))/2487067858219083 - (1284198312245721*sin((5270717853328913*x)/8388608))/106114895284014208 - (788820049541845*sin((5270717853328913*x)/16777216))/9948271432876332 + (13728271209175808*sin((5270717853328913*x)/33554432))/829022619406361 + (((1343318374775049260107797263568950807725342720*x)/6676171946239829 - 25783765124455804)*((2927114230116077*sin((3294198658330571*x)/4194304))/1152921504606846976 + (8956713847111951*sin((3953038389996685*x)/8388608))/288230376151711744 + (6532666692102853*sin((5270717853328913*x)/33554432))/9007199254740992))/2487067858219083 - (440706653985595377864088223744*power(x,2))/1983125721161459 - 4842029219725213/8589934592))/2487067858219083 - (440706653985595377864088223744*power(x,2))/1983125721161459 - 2897132367089491/70368744177664))/2487067858219083 - (440706653985595377864088223744*power(x,2))/1983125721161459 - 5794264734608811/140737488355328))/2487067858219083 - (440706653985595377864088223744*power(x,2))/1983125721161459 - 5794264734608831/140737488355328))/2487067858219083 - (440706653985595377864088223744*power(x,2))/1983125721161459 - 5794264734608831/140737488355328) + (61974373216724350012137406464*power(x,2))/8079879893910767 + 789/1000
then i can't get the plot i am using
clear all
L=25e-9;
x=0:1e-10:L;
z=(3852594936737163*sin((5270717853328913*x)/8388608))/9223372036854775808 - (5720530583262469*sin((3294198658330571*x)/4194304))/2305843009213693952 - (1890191513553995*sin((3953038389996685*x)/8388608))/72057594037927936 - (1239487464334486929408*x)/8079879893910767 + (788820049541845*sin((5270717853328913*x)/16777216))/288230376151711744 - (160878178232529*sin((5270717853328913*x)/33554432))/281474976710656 - ((2927114230116077*sin((3294198658330571*x)/4194304))/1152921504606846976 + (8956713847111951*sin((3953038389996685*x)/8388608))/288230376151711744 + (6532666692102853*sin((5270717853328913*x)/33554432))/9007199254740992)*((1259161868530272436224*x)/283303674451637 + (5720530583262469*sin((3294198658330571*x)/4194304))/79586171463010656 + (1890191513553995*sin((3953038389996685*x)/8388608))/2487067858219083 - (1284198312245721*sin((5270717853328913*x)/8388608))/106114895284014208 - (788820049541845*sin((5270717853328913*x)/16777216))/9948271432876332 + (13728271209175808*sin((5270717853328913*x)/33554432))/829022619406361 + (((2927114230116077*sin((3294198658330571*x)/4194304))/16 + (8956713847111951*sin((3953038389996685*x)/8388608))/4 + 52261333536822824*sin((5270717853328913*x)/33554432))*((1259161868530272436224*x)/283303674451637 + (5720530583262469*sin((3294198658330571*x)/4194304))/79586171463010656 + (1890191513553995*sin((3953038389996685*x)/8388608))/2487067858219083 - (1284198312245721*sin((5270717853328913*x)/8388608))/106114895284014208 - (788820049541845*sin((5270717853328913*x)/16777216))/9948271432876332 + (13728271209175808*sin((5270717853328913*x)/33554432))/829022619406361 + (((2927114230116077*sin((3294198658330571*x)/4194304))/16 + (8956713847111951*sin((3953038389996685*x)/8388608))/4 + 52261333536822824*sin((5270717853328913*x)/33554432))*((1259161868530272436224*x)/283303674451637 + (5720530583262469*sin((3294198658330571*x)/4194304))/79586171463010656 + (1890191513553995*sin((3953038389996685*x)/8388608))/2487067858219083 - (1284198312245721*sin((5270717853328913*x)/8388608))/106114895284014208 - (788820049541845*sin((5270717853328913*x)/16777216))/9948271432876332 + (13728271209175808*sin((5270717853328913*x)/33554432))/829022619406361 + (((2927114230116077*sin((3294198658330571*x)/4194304))/16 + (8956713847111951*sin((3953038389996685*x)/8388608))/4 + 52261333536822824*sin((5270717853328913*x)/33554432))*((1259161868530272436224*x)/283303674451637 + (5720530583262469*sin((3294198658330571*x)/4194304))/79586171463010656 + (1890191513553995*sin((3953038389996685*x)/8388608))/2487067858219083 - (1284198312245721*sin((5270717853328913*x)/8388608))/106114895284014208 - (788820049541845*sin((5270717853328913*x)/16777216))/9948271432876332 + (13728271209175808*sin((5270717853328913*x)/33554432))/829022619406361 + (((2927114230116077*sin((3294198658330571*x)/4194304))/16 + (8956713847111951*sin((3953038389996685*x)/8388608))/4 + 52261333536822824*sin((5270717853328913*x)/33554432))*((1259161868530272436224*x)/283303674451637 + (5720530583262469*sin((3294198658330571*x)/4194304))/79586171463010656 + (1890191513553995*sin((3953038389996685*x)/8388608))/2487067858219083 - (1284198312245721*sin((5270717853328913*x)/8388608))/106114895284014208 - (788820049541845*sin((5270717853328913*x)/16777216))/9948271432876332 + (13728271209175808*sin((5270717853328913*x)/33554432))/829022619406361 + (((1343318374775049260107797263568950807725342720*x)/6676171946239829 - 25783765124455804)*((2927114230116077*sin((3294198658330571*x)/4194304))/1152921504606846976 + (8956713847111951*sin((3953038389996685*x)/8388608))/288230376151711744 + (6532666692102853*sin((5270717853328913*x)/33554432))/9007199254740992))/2487067858219083 - (440706653985595377864088223744*power(x,2))/1983125721161459 - 4842029219725213/8589934592))/2487067858219083 - (440706653985595377864088223744*power(x,2))/1983125721161459 - 2897132367089491/70368744177664))/2487067858219083 - (440706653985595377864088223744*power(x,2))/1983125721161459 - 5794264734608811/140737488355328))/2487067858219083 - (440706653985595377864088223744*power(x,2))/1983125721161459 - 5794264734608831/140737488355328))/2487067858219083 - (440706653985595377864088223744*power(x,2))/1983125721161459 - 5794264734608831/140737488355328) + (61974373216724350012137406464*power(x,2))/8079879893910767 + 789/1000
plot(x,z)
how do i get plot i got an error Error using * Inner matrix dimensions must agree. by plot i can compare adjacent value of y(i) and by this i can know that iteration is performed well or not i am also attaching a file in which all the modification have been considered
Walter Roberson
on 10 Feb 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
on 10 Feb 2017
Sir, Thanks for your analysis and time,although as i went through your previous comment some things i couldn't understand. i am trying to understand your views. meantime if i got any other idea which can help this problem i'll defiantly share that. looking forward to your opinion.
and again Thanks for your effort and time
Walter Roberson
on 11 Feb 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
on 11 Feb 2017
Thanks for your opinion i am also doing some test on my project which is the base of this code as soon i get any results that may help i'll share with you also Sir if you have anything more that can guide me You Are Most Welcome Thank You
NILESH PANDEY
on 12 Feb 2017
Edited: NILESH PANDEY
on 13 Feb 2017
*NOTE*
Sir, after your analysis i started working on my previous work which was related to this code,when i went in depth of mathematics i have found there is some mistakes have been made in literature of this classic math which was published by some scientists on ieee. after finding the mistakes i have sent a copy of these to California Berkeley University Professor he also agreed with me,now we are working on this how to overcome mistakes so i suggested you if you are working on my code please hold this for a little more time although algorithm will be same but the values of constant will be different.
and sir thank you for your analysis after your guidance i focused my attention more on base of this mathematics and i found mistakes if you didn't guide me then may be i never bothered about this. when i'll overcome from the mistakes and i got correct code i'll discuss with You and my apologize for taking your time on a wrong code
*and also if any one working on this code kindly hold your work until i solve correct mathematics *
See Also
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)