I had same problem as others, you have to use double.Parse, my mistake was I used float.Parse and then cast to double and got rounding errors many decimals down, which was why it worked for all cases except the one that was supposed to go for 124 iterations. Parsing the text “-0.65812” as a float and then casting to double will give the value -0.658119976520538. So you have to parse it as a double from the start.
a="2+4i"
b=a.replace("i","j")
c=complex(b)
Hello,
Since this puzzle is supposed to be easy,
Could someone explain me what am i supposed to do ?
I don’t understand the puzzle at all
I am no math expert. I do not understand Mandelbrot set and its properties and applications. I know this puzzle is not difficult once you got some basic math fundamentals.
So the hardest (sometimes boring) parts come first:
First, you should study the definition of Mandelbrot set. Got an overview of what it is. (google, wiki, many edu and math web sites)
Second, by step 1, you should know that Mandelbrot set involves Complex number operations. If you do not know what is Complex number, google again to understand it.
Third, by step 1 and 2 and by the puzzle statement, you should have an equation about Mandelbrot set. Google again if you need more understanding of the equation.
Fourth, by the above studies, you should plan how to implement Complex number calculations in your programming language. For example in Java, I created a ComplexNumber class, under which I have constructors for creating Complex number objects. I have square and add methods for calculation.
I have a method to test whether the calculation will result in “diverge” status. (Don’t know what is diverge? Google helps.)
Putting them together is easy.
I still cannot solve this case after a long hours, it trouble me a lot about determine when it should be stopped
I think maybe my calculation was wrong, because I cannot understand why the 05 testcase was terminated on 124
can somebody just show me which values are correct, for example from f(1) to f(10), so I can check if my calculation was correct or wrong?
testcase 05
-0.65812-0.452i
275
1 Complex [a=-0.65812, b=-0.452]
2 Complex [a=-0.42930206559999995, b=0.1429404800000001]
3 Complex [a=-0.4942517172942038, b=-0.574729286643711]
4 Complex [a=-0.7441489928777194, b=0.11612187380585376]
5 Complex [a=-0.11784656597525855, b=-0.6248239508873994]
6 Complex [a=-1.0346371564903785, b=-0.30473328609765277]
7 Complex [a=0.3194916699346221, b=0.17857676123208882]
8 Complex [a=-0.587934732494529, b=-0.33789242468488734]
9 Complex [a=-0.42662404098601897, b=-0.05468261536192598]
10 Complex [a=-0.47910211607557995, b=-0.405342163325222]
…
123 Complex [a=-0.4137070479510352, b=-1.7138083250510097]
124 Complex [a=-3.424105453489787, b=0.9660291658215228]
my own calculation, unofficial but likely to be correct.
Hi,
So i had this problem too about the testcase 05, finding 123 instead of 124.
I figured out that : if z is a complex number like z = a + i*b,
Math.abs(a + b) != Math.sqrt(a*a + b*b)
It is supposed to be “==” since we’re in the complex set numbers.
So if you’re using the abs() function instead of the square root function, it may not work properly.
I use Java.
Using == or != to compare two float point numbers tends to get errors.
In java you can define your .equals() method to a class in which more advanced skill to compare can be used. For example you can allow a very little difference but still assume two values are equal.
hello there,
thanks for this puzzle that make me come back 20 years ago about complex number…
I get 100% ide, but i got the last test from submit how fail…
i don’t understand the meaning of the test title : “Check your absolute value”
I check it each time if it come upper 2 ! ??
any clue for this trick ?
There were comments saying this test case is to check a situation “where the absolute value of f(n) gets greater than 2 earlier than its real part and/or its imaginary part becoming greater than 2.”
Before checking the complicated logic, check the basic common issues:
- Use the highest precision of float-point data type (e.g. use double instead of float)
- do not truncate or reduce the precision throughout the program
- Parse the input string correctly. This is a bit troublesome in this puzzle. Print the two float-point values to yourself to double check you have the correct inputs.
@java_coffee_cup @CDA-20285-Gabriel-Mi thanks to you two (and the others) !! javascript may have lose me time or maybe something i did not understand even if the puzzle pass 100% !
here my results like @java_coffee_cup who was right about my input and floating parsing but :
1 real -0.65812 imaginary -0.452
2 real -0.42930206559999995 imaginary 0.1429404800000001
3 real -0.4942517172942038 imaginary -0.574729286643711
4 real -0.7441489928777194 imaginary 0.11612187380585376
5 real -0.11784656597525855 imaginary -0.6248239508873994
6 real -1.0346371564903785 imaginary -0.30473328609765277
7 real 0.3194916699346221 imaginary 0.17857676123208882
....
121 real -0.6988445992527368 imaginary -0.8395317697025564
122 real -0.8745498184351879 imaginary 0.7214044863154478
123 real -0.4137070479510352 imaginary -1.7138083250510097
=> absValue = 3.1082924965385073
123
so i follow recommandations from @CDA-20285-Gabriel-Mi and then get 124 !! but still miss something…
thanks to the forum…
cheers.