you dont need to hire me. I review the code yesterday. I wasnt able to run it with iter=30 and w=30, it is taking many time. Seems that the last part was put together, not sure why, after fix inputs to function3. Can you run the code? I tried a version with python, but I only write few lines.