Optimization problem - max independent given a function value

1 view (last 30 days)
Hi I have the following:
syms irr2 m_S s
irr1=0.05;
M=0.7;
n=120;
f=(symsum(1/(1+irr1)^s,s,1,n)-symsum(1/(1+irr2)^s,s,1,n)*(1+M*m_S)/(1+irr2)^m_S);
f must be equal zero
m_S is a variable
I wanna know which is the max irr2 ... how can I do it?

Accepted Answer

Bruno
Bruno on 1 Jul 2015

More Answers (2)

Walter Roberson
Walter Roberson on 30 Jun 2015
The max irr2 is approximately 10^7.26190814317193495613417466800 . This can be a difficult number to track down as the function is extremely steep in this area. The m_S for which the maximum occurs is approximately -1.3687669705805147932311784659488142590365365377179
You were probably expecting an answer in terms of m_S. However, if you take your f and plot it for any fixed irr2 around 1/10000, varying m_S, you will see that it peaks it the small negative values, being mostly negative. Differentiate f with respect to m_S, solve for 0, and you see that the maximum is at -(1/7)*(10*ln(1+irr2)-7)/ln(1+irr2) . The roots of f with respect to irr2 become greatest when the function is maximized with respect to m_S, as that pulls the downward-rounded shape up by the most.
So substitute that -(1/7)*(10*ln(1+irr2)-7)/ln(1+irr2) for m_S in f. Your chances of solving for the zeros are iffy as huge numbers are involved. But if you take that f and change variables to N = log10(irr2), you can plot the maximal f with respect to log10(irr2). There is one root at log10(irr2) approximately -.894057116696332445739068328606 and there is a second root at log10(irr2) approximately 7.26190814317193495613417466800. You can substitute irr2=10^7.26190814317193495613417466800 back into -(1/7)*(10*ln(1+irr2)-7)/ln(1+irr2) to get the m_S at which the value occurs.
As m_s increases past the -1.368-ish, the maximum irr2 that satisfies f=0 will decrease.
  2 Comments
Bruno
Bruno on 30 Jun 2015
Edited: Bruno on 30 Jun 2015
Walter, wonderful and thanks... is there a way to do this with fmincon with the constraint that m_S must be positive? The problem I have is that I cannot make the equation explicit for irr2 and I need to repeat the calcolus for many equations!
Could you please explain me the process of how to do it in Matlab? Thanks!

Sign in to comment.


Torsten
Torsten on 1 Jul 2015
I did not check for efficiency, but my suggestion is as follows:
1. Find analytical expressions for the sums involved (Hint: Geometric series).
Result is an explicit expression of the form f(m_s,irr2) = 0.
2. You can't solve f for irr2 in terms of m_s.
But assume irr2 = irr2(m_s).
Differentiate f(m_s,irr2(m_s)) implicitly with respect to m_s:
0=df/dm_s + df/d(irr2)*d(irr2)/dm_s.
Solving for d(irr2)/dm_s gives
d(irr2)/dm_s = - (df/dm_s) / (df/d(irr2)).
3. Solve the ordinary differential equation
d(irr2)/dm_s = - (df/dm_s) / (df/d(irr2))
with initial condition irr2(m_s=0) = irr1
using ODE45.
Use the event facility of ODE45 to detect when d(irr2)/dm_s becomes zero.
This is the value for m_s where irr2 has a local extremum.
My hope is that it's unique and a maximum.
Best wishes
Torsten.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!