This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
} } But how to modify I don't know. Write a program that reads c and the number of generations from the command line, and prints that many iterations of the Mandelbrot equation. Also print (at the beginning of the output) the value used for c. Be sure to handle all user errors (e.g. not providing two values on the command line) to the extent possible. Check the ranges of the data the user enters (e.g. don't let the number of generations be less than 0). Print an error message and exit if a value outside the allowed range is entered. Provide a default value if none is given. Detect if divergence has occurred (absolute value greater than 2) and stop output if so. Note that this test does not require you to know about or use any square root, power, exponent, or other mathematical functions that Java may or may not have. c (e.g. -0.2 + 0.8i) and Mandelbrot equation is The Mandelbrot Set is defined by a simple iterative function: zt+1 = zt2 + c z0 = 0
The Mandelbrot Set, eh? Sounds like a nasty homework assignment from back in college. The Mandelbrot Set is a beautiful thing if you can get it to do what you want it to. I actually developed an applet of The Mandelbrot Set if you or anybody else wanted to try it out ( http://www.webnelly.com/applets/mandelbrot.jsp ). Note: You need the JRE 1.3.1 plug-in from Sun for your browser for this applet. I'll try and put up some of the code soon. It's fun to struggle with it for awhile. ------------------ WebNelly.com Java/XML Web Development Check it out! http://www.webnelly.com [This message has been edited by Kris Nelson (edited November 07, 2001).]
WebNelly.com<br />Java/XML Web Development<br />Check it out!<br /><a href="http://www.webnelly.com" target="_blank" rel="nofollow">http://www.webnelly.com</a>
Joined: May 26, 2001
Hi Would you show the code for me please? I'll promise that I will not copy it, I just want a look... serious Thanks
could you tell us a bit more about what exactly you are having trouble with? It would be easier to answer your questions and in the end better for you if we could offer some help and you come to the right conclusion. You can only learn if you try...
Joined: Nov 04, 2001
Sorry Mike, My applet calculates the number of escapes for each X and Y coordinate in the grid. Therefore, the algorithm I used wouldn't be much use to you. Also, Matthew has a point. Everyone here will be glad to offer any assistance. You need to break down the problem down into parts. Based on your "specs" I recommend the following: *** Hard code a value for c and the number of iterations as opposed to getting it from the command line (which you have already done). You can worry about the validation and the rest once you know that your output is correct. *** Test the values that you have hard-coded. Your code seems to run fine, although I suggest knocking down the for loop from 100 to only 10. If you use a value for c that you know the first couple of iterations for, then you can see if the output is correct. If possible, you should test it with at least two different values for c. *** Then worry about the rest. Does the code you have posted (or are working on) currently give you the correct output based on the hard coded values?
Hi Finally I wrote the code , but it gives some errors. Would you look a the problem please?
MandelbrotUtilities.java:37: cannot resolve symbol symbol : method abs () location: class ComplexNumber ad[j] = returnNthIteration( complexnumber1, j ).abs(); ^ 2 errors
Thanks a lot [This message has been edited by Cindy Glass (edited November 08, 2001).]
Joined: Nov 04, 2001
Mike, It's a start, but we need the code for your ComplexNumber class that this class extends. The one compiler error you listed refers to the abs() method in the ComplexNumber class, so we need more code.
The message seems to imply that a method named abs() in the ComplexNumber class (or a superclass) does not exist. Maybe you called it Abs() or ABS() - remember java is case sensitive. I also think in your first code example for class Mandelbrot: double newu = 2 *(zu * zu) - zv * zv; double newv = 2 * zv * zv; this could be wrong, you might actually mean: double newu = (zu * zu) - (zv * zv); double newv = 2 * zu * zv; if you are simply squaring the complex number. [This message has been edited by Colin Kenworthy (edited November 08, 2001).]
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com