# How to use Julia to create Golden section search

**URL:** <https://discourse.julialang.org/t/how-to-use-julia-to-create-golden-section-search/36916>\
**Category:** Optimization (Mathematical)\
**Created:** [April 2, 2020, 5:45pm UTC](https://discourse.julialang.org/t/how-to-use-julia-to-create-golden-section-search/36916 "2020-04-02T17:45:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![11129](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/11129/32/13818_2.png) [@11129](https://discourse.julialang.org/u/11129)\
**Post date:** [April 2, 2020, 5:45pm UTC](https://discourse.julialang.org/t/how-to-use-julia-to-create-golden-section-search/36916/1 "2020-04-02T17:45:37Z")

</div>

How to use code to reach the Golden section search.

---

<div class="post-metadata">

**Author:** ![Tero\_Frondelius](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tero_frondelius/32/7629_2.png) [@Tero\_Frondelius](https://discourse.julialang.org/u/Tero_Frondelius)\
**Post date:** [April 2, 2020, 5:51pm UTC](https://discourse.julialang.org/t/how-to-use-julia-to-create-golden-section-search/36916/2 "2020-04-02T17:51:52Z")

</div>

Hi. Welcome to the forum. Is this your homework? We have a common agreement not to give answers to homework assignments.

---

<div class="post-metadata">

**Author:** ![11129](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/11129/32/13818_2.png) [@11129](https://discourse.julialang.org/u/11129)\
**Post date:** [April 2, 2020, 6:10pm UTC](https://discourse.julialang.org/t/how-to-use-julia-to-create-golden-section-search/36916/3 "2020-04-02T18:10:06Z")

</div>

Thank you for responding,

Actually, it’s an additional work.  
The assignment is required to solve by Matlab, I’m done.  
Then professor mentions we could try to use Julia(don`t mandatory).  
I met some problems cuz it was a little different with Matlab.  
I just hope to get some thoughts to understand Julia, (not specific codes).

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [April 2, 2020, 6:26pm UTC](https://discourse.julialang.org/t/how-to-use-julia-to-create-golden-section-search/36916/4 "2020-04-02T18:26:14Z")

</div>

If you have any specific questions, I’m sure people would be happy to help.

---

<div class="post-metadata">

**Author:** ![tbeason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbeason/32/15898_2.png) [@tbeason](https://discourse.julialang.org/u/tbeason)\
**Post date:** [April 2, 2020, 7:13pm UTC](https://discourse.julialang.org/t/how-to-use-julia-to-create-golden-section-search/36916/6 "2020-04-02T19:13:16Z")

</div>

Well the best thing about Julia is that you can basically write the code as you would write the math (even with the LaTeX symbols if you want!). So, that’s where I would start. You start with an objective function and an initial interval. How do you find your first guess, then your next, etc. That’s all math. Just make that into code, line by line.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [April 3, 2020, 5:22am UTC](https://discourse.julialang.org/t/how-to-use-julia-to-create-golden-section-search/36916/7 "2020-04-03T05:22:39Z")

</div>

It is not really different from implementing any other algorithm in Julia, you don’t need to do anything special.

If you post concrete code that you are stuck with, it is more likely that people can help you.
