finding the minimum of an equation | Traders Hideout

finding the minimum of an equation

Berlin, Europe

Broker/Data: Interactive Brokers
Favorite Futures: Keyboard

Posts: 9,779 since Mar 2010

 Hey I am trying to get the minimum value of curves in NT7 (C#) in the most resource efficient way. The equation of one curve is: y= |-22-16x|+|44-22x|+|21-25x|+|40-22x|+|6-11x|+|12-4x| They always have and only one minimum point and they look like something like this: Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s). Actually I am looking for the value of x when y is lowest. Any help is appreciated!

This is a funny little puzzle!

If I look at your function it is built from six components, each component being the absolute amount of a linear function. Now let us look at a component function, for example

y1 = |-22-16x|

This function has two linear legs, a descending leg on the left side and and a rising leg on the right side. For x = -1.375 it takes the value zero.

The same is true for the other five component functions. Each of them is built from two legs and has a low point, where it takes the value 0. I conclude that the function y that you have exposed, has six points where it is not differentiable. Newton-Raphson cannot be used.

However, your function has another property, which makes a solution easy. With the exception of the low points of the six component functions your function can be built by adding six linear functions. Therefore it is linear itself between two low points. As a consequence one of the low points of the component function is the minimum for which you are looking.

Therefore you just need to calculate x1, x2, x3, x4, x5, x6 representing the low points of the component functions and then find out for which of those the function

y = |-22-16x|+|44-22x|+|21-25x|+|40-22x|+|6-11x|+|12-4x|

takes the lowest value.

 The following 4 users say Thank You to Fat Tails for this post: