# "Avoid local maximums"

**URL:** <https://ziggit.dev/t/avoid-local-maximums/6676>\
**Category:** Explain\
**Created:** [November 4, 2024, 9:09am UTC](https://ziggit.dev/t/avoid-local-maximums/6676 "2024-11-04T09:09:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![n0s4](https://ziggit.dev/user_avatar/ziggit.dev/n0s4/32/2227_2.png) [@n0s4](https://ziggit.dev/u/n0s4)\
**Post date:** [November 4, 2024, 9:09am UTC](https://ziggit.dev/t/avoid-local-maximums/6676/1 "2024-11-04T09:09:04Z")

</div>

The `zig zen` states:

```zig
* Avoid local maximums.

```

but what does this mean exactly?

---

<div class="post-metadata">

**Author:** ![tensorush](https://ziggit.dev/letter_avatar_proxy/v4/letter/t/6a8cbe/32.png) [@tensorush](https://ziggit.dev/u/tensorush)\
**Post date:** [November 4, 2024, 9:17am UTC](https://ziggit.dev/t/avoid-local-maximums/6676/2 "2024-11-04T09:17:51Z")

</div>

I remember @andrewrk talking about this one here:

[![](https://ziggit.dev/uploads/default/original/2X/9/9f25c7e9b3fd8d66e034d5bc35f1c39131fa5bdc.jpeg "S2, E7: Taking the warts off C, with Andrew Kelley, creator of the Zig Software Foundation") ](https://www.youtube.com/watch?v=gn3YsZ6HUHw&t=2375)

---

<div class="post-metadata">

**Author:** ![n0s4](https://ziggit.dev/user_avatar/ziggit.dev/n0s4/32/2227_2.png) [@n0s4](https://ziggit.dev/u/n0s4)\
**Post date:** [November 4, 2024, 9:22am UTC](https://ziggit.dev/t/avoid-local-maximums/6676/3 "2024-11-04T09:22:43Z")

</div>

Thanks, so basically: “don’t be afraid to abandon the best version of a mediocre solution in order to find a better solution”. Good advice.

---

<div class="post-metadata">

**Author:** ![videbar](https://ziggit.dev/letter_avatar_proxy/v4/letter/v/e480ec/32.png) [@videbar](https://ziggit.dev/u/videbar)\
**Post date:** [November 4, 2024, 12:58pm UTC](https://ziggit.dev/t/avoid-local-maximums/6676/4 "2024-11-04T12:58:23Z")

</div>

This terminology comes from [optimization problems](https://en.wikipedia.org/wiki/Optimization_problem), where ideally you want to find the **global** maximum (i.e., the best possible solution) in a given space but you may get stuck at a local maximum.

You can think of optimization problems as trying to find the highest point in a unknown landscape. Search algorithms typically start at a given point and move around trying to go uphill at each iteration. Once they reach the top of a hill, they can be sure that they found they highest point in their vicinity (a local maximum) but an even highest hill may exist somewhere else (the global maximum). Furthermore, since they would need to go downhill to continue exploring, they instead get stuck as this local maximum.
