Problem in minimizing expression

I am trying to implement bootstrapping (https://en.wikipedia.org/wiki/Bootstrapping_(finance)) of CDS curve. To implement it I am trying to minimize a series of expression. The minimum value of expression will result from certain value of variable. I can easily do it in excel however trying to find a way in mathematica.

I am trying to find value of h1 and h2 in below code using Minimize function to minimize two expression.

'Minimize[Sum[50/10000*1/4*1/4*n*97/100*Exp[-h1*1/4*n], {n, 1, 4}] -
Sum[1/2*1/4*n*97/100*(Exp[-h1*1/4*(n - 1)] - Exp[-h1*1/4*n]), {n, 1, 4}]
&&
Sum[77/10000*1/4*1/4*n*97/100*Exp[-h1*1/4*n], {n, 1, 4}] +
Sum[77/10000*1/4*1/4*n*94/100*Exp[-h2*1/4*n], {n, 5, 8}] -
Sum[1/2*1/4*n*97/100*(Exp[-h1*1/4*(n - 1)] - Exp[-h1*1/4*n]), {n, 1, 4}] +
Sum[1/2*1/4*n*94/100*(Exp[-h1*1/4*(n - 1)] - Exp[-h2*1/4*n]), {n, 5}] +
Sum[1/2*1/4*n*94/100*(Exp[-h2*1/4*(n - 1)] - Exp[-h2*1/4*n]), {n, 6,8}],
{h1, h2}, Reals]'

I get following output but doesn't give values of h1 and h2 which will minimize the expression. I get h1 = 0.01148 and h2 = 0.01451 when I use goal seek in excel. Can anybody help in trouble shooting the issue in Minimize function

Minimize[(97 E^-h1)/80000 + (291 E^(-3 h1/4))/320000 + (97 E^(-h1/2))/
160000 + (97 E^(-h1/4))/320000 - 97/200 (-E^-h1 + E^(-3 h1/4)) -
291/800 (-E^(-3 h1/4) + E^(-h1/2)) - 97/800 (1 - E^(-h1/4)) -
97/400 (-E^(-h1/2) + E^(-h1/4)) && (7469 E^-h1)/4000000 + (
22407 E^(-3 h1/4))/16000000 + (7469 E^(-h1/2))/8000000 + (
7469 E^(-h1/4))/16000000 + (3619 E^(-2 h2))/1000000 + (
25333 E^(-7 h2/4))/8000000 + (10857 E^(-3 h2/2))/4000000 + (
3619 E^(-5 h2/4))/1600000 - 97/200 (-E^-h1 + E^(-3 h1/4)) -
291/800 (-E^(-3 h1/4) + E^(-h1/2)) - 97/800 (1 - E^(-h1/4)) -
97/400 (-E^(-h1/2) + E^(-h1/4)) + 47/50 (-E^(-2 h2) + E^(-7 h2/4)) +
329/400 (-E^(-7 h2/4) + E^(-3 h2/2)) + 47/80 (E^-h1 - E^(-5 h2/4)) +
141/200 (-E^(-3 h2/2) + E^(-5 h2/4)) + 47/100 (E^(-3 h1/4) - E^-h2) +
141/400 (E^(-h1/2) - E^(-3 h2/4)) + 47/200 (E^(-h1/4) - E^(-h2/2)) +
47/400 (1 - E^(-h2/4)), {h1, h2}, Reals]
• Are you trying to minimize 2 expressions with the && ? – b.gates.you.know.what Jun 13 '15 at 16:46
• yes there are two expression. First expression only uses h1 but second expression uses h1 and h2 – Kausik Jun 13 '15 at 16:47

expr1 = Sum[50/10000*1/4*1/4*n*97/100*Exp[-h1*1/4*n], {n, 1, 4}] -
Sum[1/2*1/4*n*97/100*(Exp[-h1*1/4*(n - 1)] - Exp[-h1*1/4*n]), {n, 1, 4}];

expr2 = Sum[77/10000*1/4*1/4*n*97/100*Exp[-h1*1/4*n], {n, 1, 4}] +
Sum[77/10000*1/4*1/4*n*94/100*Exp[-h2*1/4*n], {n, 5, 8}] -
Sum[1/2*1/4*n*97/100*(Exp[-h1*1/4*(n - 1)] - Exp[-h1*1/4*n]), {n, 1, 4}] +
Sum[1/2*1/4*n*94/100*(Exp[-h1*1/4*(n - 1)] - Exp[-h2*1/4*n]), {n, 5}] +
Sum[1/2*1/4*n*94/100*(Exp[-h2*1/4*(n - 1)] - Exp[-h2*1/4*n]), {n, 6, 8}];

Plot3D[{expr1, expr2}, {h1, -5, 5}, {h2, -5, 5}, ClippingStyle -> None,
PlotLegends -> "Expressions"] You must minimize some function of the two expressions

NMinimize[#, {h1, h2}] & /@
{Abs[expr1*expr2], Abs[expr1 + expr2],
expr1^2 + expr2^2} You may also wish to constrain the region of interest.

NMinimize[{expr1^2 + expr2^2, h1 >= 0, h2 >= 0}, {h1, h2}] EDIT: Your comment below indicates that you desire both expressions to be zero

NSolve[{expr1 == 0, expr2 == 0}, {h1, h2}, Reals]

{{h1 -> 0.00998752, h2 -> -0.000767111}}

• thanks. not sure why h2 is so far away from what I get from excel goal seek. I expect h2 to be bigger than h1 in this particular case as second expression starts with 77 but 1st expression starts with 50. h is supposed to fit exponential function p= exp(-h*t), p = 1 when t =0, h is increasing function but peicewise constant. In this case constant between n = 1 to 4 which is h1. h increased and again constant between n =5 to 8 which is h2. Can you pl suggest how do I modify your code to take into these property of h? – Kausik Jun 13 '15 at 18:01
• I need to minimize a system of five equation using h1 to h5. Can I just use the same logic as given in your code and extend it to 5 equation please – Kausik Jun 13 '15 at 18:02
• Can you pl explain why you decided to minimize {Abs[expr1*expr2], Abs[expr1 + expr2], expr1^2 + expr2^2}? What are alternatives available please? Is that something you decide after seeing how the expression behaves after plotting in a graphical format pleas? – Kausik Jun 13 '15 at 18:11
• However many expressions you have, you need to define a function of those expressions that you want to minimize. In your Excel solution, what function of the expressions were you minimizing? – Bob Hanlon Jun 13 '15 at 18:11
• Your second expression goes to minus infinity as h2 approaches minus infinity. Consequently, to get a minimum other than minus infinity the range must be constrained or the function to be minimized must use the Abs, square, or similar function of expr2. – Bob Hanlon Jun 13 '15 at 18:19