From: SourceForge.net <no...@so...> - 2008-04-23 00:30:31
|
Bugs item #1940411, was opened at 2008-04-11 15:03 Message generated for change (Comment added) made by rtoy You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=1940411&group_id=4933 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Lisp Core - Plotting Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Nobody/Anonymous (nobody) Assigned to: Nobody/Anonymous (nobody) Summary: adaptive plotting fooled by periodic function Initial Comment: f(x):=sin(4*%pi*x) y:f(x) then, drawing the graph, gets a corrupted sin wave. This problem does not occur if using 2 or 3 intead of 4 in the sin argument, and also it does not occur if typing 3.14 instead of using the %pi constant. Tested using version 0.7.4 of Maxima under Win. ---------------------------------------------------------------------- >Comment By: Raymond Toy (rtoy) Date: 2008-04-22 20:30 Message: Logged In: YES user_id=28849 Originator: NO I have no problem if you want to change nticks to be some other value. But maybe we should use a larger value, say 47 or 53 or some other prime. Anything other than changing nticks would probably require a huge amount of analysis by maxima to determine sensible values. Nticks is a simple and easily explained way to get more accurate plots. Also, I forgot to mention I'd be opposed to some sort of random sampling. It would be had to explain to users, and it would be annoying if you replot and the graph changes due do different samples being taken. :-) ---------------------------------------------------------------------- Comment By: Robert Dodier (robert_dodier) Date: 2008-04-22 19:50 Message: Logged In: YES user_id=501686 Originator: NO > Look at what samples are used in plotting the function with the > default of nticks = 10. The samples are at k/2, so we evaluate > the function at sin(2*k*%pi). If we had perfect accuracy, > every sample would be 0. Yes, that is what I meant when I said the adaptive plotter is fooled by periodic functions. > That ntick=7 works better is because the sample values aren't > all zero, and the adaptive plotter refines the data. Is it OK with you if I change nticks from 10 to something like 7 or 13 or 17 ? It doesn't solve the problem but it might make it slightly less likely to be encountered. ---------------------------------------------------------------------- Comment By: Raymond Toy (rtoy) Date: 2008-04-21 11:27 Message: Logged In: YES user_id=28849 Originator: NO Look at what samples are used in plotting the function with the default of nticks = 10. The samples are at k/2, so we evaluate the function at sin(2*k*%pi). If we had perfect accuracy, every sample would be 0. What do you expect the adaptive plotter to do? I think the only reason the plot even begins to look right is that round-off error confuses the adaptive plotter to use more samples. That ntick=7 works better is because the sample values aren't all zero, and the adaptive plotter refines the data. The original plotting algorithm just took nticks samples and plotted them. The default was 100, I think. So plot of sin(100*%pi*x) would fail. You fundamentally have to sample enough (Nyquist theorem tells us so for uniform sampling). The adaptive plotter just makes the plots smoother because we don't use the correct right interpolating function. For the issue where the function is undefined, this is not the fault of the adaptive plotter. Maxima currently doesn't really do anything to indicate that. No error or anything. If maxima could signal an error, the adaptive plotter could catch that and stop trying to refine that area. Might be possible to teach the plotter to be more careful in these cases, but I think it might be tricky. ---------------------------------------------------------------------- Comment By: Robert Dodier (robert_dodier) Date: 2008-04-19 12:09 Message: Logged In: YES user_id=501686 Originator: NO > You fundamentally have to sample enough. Then adaptive plotting just helps out by automatically sampling more in places the appear to need it. Ray, I'm sorry, but this just isn't so. The problem is not the lack of samples. nticks=7 (vs nticks=10, the default) yields a nice-looking graph. The problem is that the adaptive plotting algorithm samples at regular intervals. If the function is periodic, it can be fooled into thinking the function is constant. It turns out such functions are easy to construct e.g. plot2d(sin(4*%pi*x), [x, 0, 10]). A simple-minded workaround is to change nticks to some number e.g. nticks=17 which makes the problem go away for some cases but it is still possible to construct a simple function which fools it. Probably the adaptive plotting code should sample irregularly (at random or quasi-random locations) but that is more work. > I would be interested in any other idiosyncrasies you see with adaptive plotting. The major problem that comes to mind is that the adaptive plotter tries too hard where the function is undefined (i.e. returns a nonnumeric value). It appears to hang but actually it is just progressing very slowly. Maybe the plotter could attempt some analysis to determine the domain of the function. That capability (which, I know, would be a lot of work) would be useful in general. ---------------------------------------------------------------------- Comment By: Raymond Toy (rtoy) Date: 2008-04-18 12:45 Message: Logged In: YES user_id=28849 Originator: NO I believe that nticks is too small. With or without adaptive plotting, nticks indicates how many samples to take. Before adaptive plotting, I think the default nticks was 100. If the graph looked weird, everyone just bumped up nticks. Adaptive plotting makes it a little easier to get nice looking plots, but if the choice of the x-range and nticks is such that the nticks samples all look pretty much the same, adaptive plotting isn't going to help. You fundamentally have to sample enough. Then adaptive plotting just helps out by automatically sampling more in places the appear to need it. I would be interested in any other idiosyncrasies you see with adaptive plotting. ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2008-04-16 01:02 Message: Logged In: NO > look for "ticks" and increase it to say 500 or more. Well, I don't think it's correct to say the value of nticks is too small. The problem is that the adaptive plotting algorithm in plot2d is easily fooled into thinking that a function is constant. You can get better results by making nticks a prime number, say 7 or 11 (the default is 10). e.g. plot2d (sin(4*%pi*x), [x, 0, 10]); => spurious flat parts plot2d (sin(4*%pi*x), [x, 0, 10], [nticks, 11]); => looks right To resolve this we probably need to rethink the adaptive plotting stuff. If I'm not mistaken it has other idiosyncrasies. As a stop-gap measure maybe we can change the default value of nticks to 11. Robert Dodier (not logged in) ---------------------------------------------------------------------- Comment By: Barton Willis (willisbl) Date: 2008-04-12 01:49 Message: Logged In: YES user_id=895922 Originator: NO I'm guessing that you used wxMaxima 0.74 and used the ploting --> plot2d menu item. The default for the number of ticks was too small in that version. In the menu box, look for "ticks" and increase it to say 500 or more. I think there is a wxMaxima 0.74a that has a larger value for the default for ticks. Maybe you can look for that. wxMaxima 0.74sa might be part of Maxima 5.14.0 now --- I think some Maxima versions 5.14.0 have wxMaxima 0.74 and others 0.74a. ---------------------------------------------------------------------- Comment By: Raymond Toy (rtoy) Date: 2008-04-11 15:49 Message: Logged In: YES user_id=28849 Originator: NO Show exactly what you did. In what way is the sine wave corrupted? What does build_info() say? Are you really using Maxima 0.7.4? Is that the wxmaxima version? I don't recall any 0.7.4 version of Maxima. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=1940411&group_id=4933 |