# UnitMath Examples ( Global Extremes )

### email Examples FAQ Home Sales \$\$\$ What's New Windows demo

When inexact variables are used in a equation multiple times the answer often have many local extremes. To find the global extremes ( the right answer ) UnitMath automatically starts a search using a customized form of interval calculations. This approach guarantees that both the global maxima and minima will be found. The search can however take some time. Generally the search time is only a few seconds, and you can abort the calculation at any time.

Following are several examples where UnitMath uses the search engine to find the global extremes.

x: -1 to 3;
(x+1)(x-3) ~ -4.000 to -4 to 0

x: -1 to 3;
(x+1)(x-1)(x-3) ~ 0 ± 3.079

x:-1 to 1;
512 x^10 -1280 x^8+1120x^6-400x^4+50x^2-1 ~ -1.000 to -1 to 1.000

x: 1 to inf
sin(x)/x ~ -0.217 to 0.841 to 0.841

x:2 to 2 to 500; y: 2 to 2 to 500;
sin( x y )/(x y) ~ -0.217 to -0.189 to 0.128

x:2 to 2 to 500; y: 2 to 2 to 500;
sin( x y )/(x y) + y/10 ~ -0.017 to 0.011 to 50.001

Equations solved using the search enging may have units.

"The length of a parabola is approximately:"
Parabola_Len: width( 1+ 8/3* ratio^2 - 32/5 * ratio^4 ) as ft;
ratio: height/width;
height: (18 to 20) ft; width: ( 90 to 93 ) ft;
Parabola_Len ~ ( 98.678 to 100.932 to 103.196 ) ft

"The length of a ellipse is approximately:"
length: pi(a+b)(1+ r^2 / 4 + r^4 / 64) as ft
r: (a-b)/(a+b);
a: ft ± inch; b: 10 ft ± inch;
length ~ ( 40.160 to 40.583 to 41.009 ) ft

Following are several standard test cases for finding the global minima. In many of the cases below I've added 1 to the function. This makes the extremes easier for UnitMath to find, and I do not agree with the common practice of assuming anything less than 10^-15 is zero. For example, there is a huge difference between a microFarad and a picoFarad.

" Six hump camel back "
x:-5 to 5; y:-5 to 5;
4 x^2 -(2.1±0)x^4+x^6/3 + x y 2 - 4 y^2 + 4 y^4 ~ -1.653 to 0 to 6,445.833

" Beale 1 "
x:-4.5 to 4.5; y:-4.5 to 4.5;
((1.5±0)-x+ x y )^2 +( (2.25±0)-x+x y^2 )^2+ ((2.625±0) - x + x y^3)^2 ~ 0 to 14.203 to 198,248.014

" Booth ( + 1 )"
x:-10 to 10; y:-10 to 10;
(x + 2 y - 7 )^2 +( 2 x + y - 5)^2 + 1 ~ 1.000 to 75 to 2,595

" Branin "
x:-5 to 10; y:0 to 15;
( y -(5.1±0)/(4 sq pi) y^2 + 5/pi x - 6 )^2 + 10( 1- 1/(8 pi))cos(x) +10

~ 0.397887358 to 5.503396923 to 798.083000759
~ 0.397887 to 5.503397 to 798.083001

" Rastrigin "
x:-1 to 1; y:-1 to 1;
x^2 + y^2 - cos(12 x) - cos(18 y) ~ -2 to -2 to 3.392

" Griewank "
x:-100 to 100; y:-100 to 100;
( x^2 + y^2)/200 - cos(x)cos(y/sqrt(2)) + 1 ~ 0 to 0 to 101.021

x:-600 to 6000; y:-600 to 6000;
"0:05"( x^2 + y^2)/200 - cos(x)cos(y/sqrt(2)) + 1 ~ 0 to 72,901.122812202 to 360,000.927591596

" Treccani ( + 1 )"
x:-5 to 5; y:-5 to 5;
x^4 + 4 x^3 + 4 x^2 + y^2 + 1 ~ 1.000 to 1 to 1,251

" Three Hump Camel Back "
x:-5 to 5; y: -5 to 5;
2 x^2 -(1.05±0)x^4 + x^6/6 + x y + y^2 ~ 0 to 0 to 2,047.917

" Three Hump Camel Back ( + 1 )"
2 x^2 -(1.05±0)x^4 + x^6/6 + x y + y^2 + 1 ~ 1.000 to 1 to 2,048.917

" Branin2 ( + 1 )"
x:-5 to 5; y: -5 to 5;
( 1 - 2 y + 1/20 sin ( 4 pi y) - x )^2 + ( y- 1/2 sin( 2 pi x) )^2 + 1 ~ 1.000 to 2 to 282