1
00:00:00,000 --> 00:00:01,589
In this video we're gonna be talking about

2
00:00:01,589 --> 00:00:04,620
how we can use this ChatGPT for debugging.

3
00:00:04,620 --> 00:00:06,900
Now let's just go ahead and ask

4
00:00:06,900 --> 00:00:09,210
ChatGPT to create something for us

5
00:00:09,210 --> 00:00:11,730
and then we're gonna intentionally mess it up

6
00:00:11,730 --> 00:00:14,250
just to kind of simulate what it would've been like

7
00:00:14,250 --> 00:00:15,930
if we had written something ourselves

8
00:00:15,930 --> 00:00:17,130
that was maybe incorrect

9
00:00:17,130 --> 00:00:19,410
or missing a crucial line of code

10
00:00:19,410 --> 00:00:21,240
or a piece of logic that we just,

11
00:00:21,240 --> 00:00:24,210
'cause we're humans, we're subject to mistakes.

12
00:00:24,210 --> 00:00:25,860
Just maybe we just forgot about something, right?

13
00:00:25,860 --> 00:00:28,230
So let's see if ChatGPT can actually help us

14
00:00:28,230 --> 00:00:29,700
with the debugging process

15
00:00:29,700 --> 00:00:31,870
and kind of reading through our code

16
00:00:31,870 --> 00:00:33,870
with knowledge of the problem spec.

17
00:00:33,870 --> 00:00:35,220
And then just trying to figure out

18
00:00:35,220 --> 00:00:37,170
what could have possibly went wrong.

19
00:00:37,170 --> 00:00:40,587
So first let's ask it an interesting question.

20
00:00:40,587 --> 00:00:41,800
Let's see if, could you

21
00:00:43,140 --> 00:00:46,593
generate the Mandelbrot set?

22
00:00:48,750 --> 00:00:51,130
Or rather could you generate a visualization

23
00:00:52,200 --> 00:00:55,173
of the Mandelbrot set in Python?

24
00:00:56,250 --> 00:00:58,590
Now this is, so the, if you don't know,

25
00:00:58,590 --> 00:01:01,380
the Mandelbrot set is a fractal,

26
00:01:01,380 --> 00:01:04,200
which is basically when viewed, it's like

27
00:01:04,200 --> 00:01:07,230
infinite complexity as you continue to zoom in and zoom in

28
00:01:07,230 --> 00:01:09,510
and it's basically a mathematical function.

29
00:01:09,510 --> 00:01:12,030
And yeah, so it's able to do that.

30
00:01:12,030 --> 00:01:13,800
So if you go ahead and copy the code here,

31
00:01:13,800 --> 00:01:15,120
this is some beautiful code right here.

32
00:01:15,120 --> 00:01:17,820
It's literally telling us, it's giving us comments

33
00:01:17,820 --> 00:01:19,320
for everything and telling us what

34
00:01:19,320 --> 00:01:21,870
each and every line of code is doing.

35
00:01:21,870 --> 00:01:23,070
But yeah, let's go ahead

36
00:01:23,070 --> 00:01:25,950
and create a file for that real quick.

37
00:01:25,950 --> 00:01:27,520
So, Mandelbrot.py

38
00:01:28,830 --> 00:01:31,680
and, oh, I think I stole it when it was

39
00:01:31,680 --> 00:01:33,090
not done generating stuff.

40
00:01:33,090 --> 00:01:36,660
So let's go ahead and wait for that to finish writing.

41
00:01:36,660 --> 00:01:39,300
So now it's gonna go ahead and tell us what's going on.

42
00:01:39,300 --> 00:01:42,960
Generates a square image of the set with 500 by 500 pixels.

43
00:01:42,960 --> 00:01:46,080
So if we go and take that

44
00:01:46,080 --> 00:01:47,400
and we run it, let's see

45
00:01:47,400 --> 00:01:50,130
what it gives us without like kind of messing with anything.

46
00:01:50,130 --> 00:01:52,230
So we actually know what we're working with here.

47
00:01:52,230 --> 00:01:53,680
Well, that looks really cool.

48
00:01:54,870 --> 00:01:56,490
Yeah, so that's the Mandelbrot set.

49
00:01:56,490 --> 00:01:58,500
I can go ahead and zoom in here.

50
00:01:58,500 --> 00:02:02,820
As you can see, it's a, it's not really infinitely detailed

51
00:02:02,820 --> 00:02:05,280
as I've not made the size too large,

52
00:02:05,280 --> 00:02:07,050
but that's something I can tweak here.

53
00:02:07,050 --> 00:02:09,810
Let's see if we can kind of mess with this thing, right?

54
00:02:09,810 --> 00:02:12,090
So this is like a very crucial part of the math here.

55
00:02:12,090 --> 00:02:16,053
So if I, let's say mess with this, let's say 1.

56
00:02:16,980 --> 00:02:20,010
I'm, I'm interested in what this will look like.

57
00:02:20,010 --> 00:02:21,990
Probably wrong.

58
00:02:21,990 --> 00:02:24,450
Yeah, so that looks very strange

59
00:02:24,450 --> 00:02:26,040
and that's definitely not what we expected.

60
00:02:26,040 --> 00:02:28,320
Let's, let's mess it up even more.

61
00:02:28,320 --> 00:02:33,090
So if we do that, this will definitely, oh yeah, we've,

62
00:02:33,090 --> 00:02:34,770
we've completely destroyed it.

63
00:02:34,770 --> 00:02:37,440
So let's, let's ask it.

64
00:02:37,440 --> 00:02:42,440
This is my code for displaying the Mandelbrot set.

65
00:02:44,460 --> 00:02:45,663
What is wrong with it?

66
00:02:49,920 --> 00:02:53,703
And then let's go ahead and copy that in here.

67
00:02:57,060 --> 00:02:58,140
Your code looks mostly correct,

68
00:02:58,140 --> 00:03:00,000
but there is a small issue with the formula used

69
00:03:00,000 --> 00:03:02,370
to calculate the iterative sequence for each point.

70
00:03:02,370 --> 00:03:04,110
The Mandelbrot set is defined as a set

71
00:03:04,110 --> 00:03:08,190
of complex number C versus the sequence Z times N plus 1

72
00:03:08,190 --> 00:03:12,390
is equivalent to Z of N to the power of 2

73
00:03:12,390 --> 00:03:13,740
plus C does not diverge.

74
00:03:13,740 --> 00:03:15,210
So this is basically just the math

75
00:03:15,210 --> 00:03:17,790
behind this really beautiful fractal,

76
00:03:17,790 --> 00:03:20,910
but yeah, it, it's able to point out exactly,

77
00:03:20,910 --> 00:03:22,980
so like, it's saying you've modified the formula

78
00:03:22,980 --> 00:03:24,240
to be this instead,

79
00:03:24,240 --> 00:03:27,120
which changes the nature of the set being generated.

80
00:03:27,120 --> 00:03:29,730
So if you go ahead and fix that real quick,

81
00:03:29,730 --> 00:03:31,170
it should give us the right answer again.

82
00:03:31,170 --> 00:03:33,750
And that's, that's really funny 'cause it almost

83
00:03:33,750 --> 00:03:34,950
knows exactly what we did.

84
00:03:34,950 --> 00:03:36,270
We've modified the formula.

85
00:03:36,270 --> 00:03:38,430
That's, that's a funny way of wording it.

86
00:03:38,430 --> 00:03:39,630
But yeah, we can see

87
00:03:39,630 --> 00:03:41,940
that it's once again giving us the code

88
00:03:41,940 --> 00:03:44,190
pretty much the same thing as what it gave before.

89
00:03:44,190 --> 00:03:47,280
I don't see any really big changes here,

90
00:03:47,280 --> 00:03:48,480
but yeah, we can see that,

91
00:03:48,480 --> 00:03:50,160
that the two numbers we had modified,

92
00:03:50,160 --> 00:03:52,803
this became 1.5, this became 1, I believe.

93
00:03:53,670 --> 00:03:55,470
Those, those are back to normal, right?

94
00:03:55,470 --> 00:03:57,720
And that's funny, that it's able to kind of

95
00:03:57,720 --> 00:03:59,790
just pick out on exactly what was wrong

96
00:03:59,790 --> 00:04:01,290
'cause it knew what was right.

