Results 1 to 2 of 2

Math Help - find the initial value of a function - matlab

  1. #1
    Newbie
    Joined
    Mar 2009
    Posts
    1

    find the initial value of a function - matlab

    Hi all !

    I have quite not very spectucular function and
    I need to get with an initial value x(1), which I dont know yet, a sum of e.g. 10. I "programmed" a loop and find empirically an initial value of 9.47 to get a sum of 10 for this function (with 10 time steps). But this is either a sophisticated nor a mathematical solution.
    here the function:

    a=4 %phi, mean reversion
    s=1 %local volatility
    n=10 %years, time steps
    x(1)=?

    for i=2:n
    x(i)=4*x(i-1)*s^2/(1+sqrt(1+4*x(i-1)*a*s^2))^2
    end
    out=sum(x)

    Do you need bisections methods ? If yes, how I implement one for this ?
    I am not a mathematicien so I would be very gratefull for any suggestions !
    Thanks a lot in advance !
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by hypokrit View Post
    Hi all !

    I have not very spectucular function and
    I need to get with an initial value x(1), which I dont know yet, a sum of e.g. 10. I "programmed" a loop and find empirically an initial value of 9.47 to get a sum of 10 for this function (with 10 time steps). But this is either a sophisticated nor a mathematical solution.
    here the function:

    a=4 %phi, mean reversion
    s=1 %local volatility
    n=10 %years, time steps
    x(1)=?

    for i=2:n
    x(i)=4*x(i-1)*s^2/(1+sqrt(1+4*x(i-1)*a*s^2))^2
    end
    out=sum(x)

    Do you need bisections methods ? If yes, how I implement one for this ?
    I am not a mathematicien so I would be very gratefull for any suggestions !
    Thanks a lot in advance !
    Recode this as a function ff(x) where x will be the initial value and ff(x)=0 when your sum is 10. so something like this:

    Code:
    function rv=ff(x0)
     
      a=4 %phi, mean reversion 
      s=1 %local volatility 
      n=10 %years, time steps 
     
      x=zeros(1,10);
      x(1)=x0;
     
      for i=2:n 
        x(i)=4*x(i-1)*s^2/(1+sqrt(1+4*x(i-1)*a*s^2))^2 
      end 
     
      rv=sum(x)-10;
    Now you use a numerical root finder on this.

    CB
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Replies: 1
    Last Post: October 15th 2011, 11:28 PM
  2. Find a Particular Solution, given initial condition
    Posted in the Differential Equations Forum
    Replies: 3
    Last Post: September 30th 2010, 10:33 AM
  3. find the minimum initial speed....
    Posted in the Calculus Forum
    Replies: 1
    Last Post: September 29th 2010, 07:03 AM
  4. find initial speed
    Posted in the Advanced Applied Math Forum
    Replies: 5
    Last Post: September 16th 2008, 06:36 PM
  5. Find the initial investment?
    Posted in the Business Math Forum
    Replies: 3
    Last Post: July 11th 2006, 08:59 AM

Search Tags


/mathhelpforum @mathhelpforum