Post Reply 
Solve: "bad guess(es)" error...
05-31-2015, 10:31 AM (This post was last modified: 05-31-2015 10:53 AM by DrD.)
Post: #2
RE: Solve: "bad guess(es)" error...
Hi Salvo;

The program's local vars don't persist within the Solve app (out of scope). If you use Globals (see the reserved vars in the code below), the program works fine.

<<A subroutine *could* be used to pass locals to reserved vars, and return the results back to yield, if necessary.>>

Code:

EXPORT provasol()
BEGIN
  local yield, coupon, ann, years, price;

// Using reserved vars as globals
  C:=6.75;
  A:=2;
  Y:=14;
  P:=122.125;

//  Locals don't persist in Solve App
  //coupon:=6.75;
  //ann:=2;
  //years:=14;
  //price:=122.125;

  //yield := Solve.SOLVE((coupon/ann)*( (1-1/(1+(X/ann))^(ann*years)) / (X/ann) ) + 100/(1+(X/ann))^(ann*years) = price, X);
  
  yield := Solve.SOLVE((C/A)*( (1-1/(1+(X/A))^(A*Y)) / (X/A) ) + 100/(1+(X/A))^(A*Y) = P, X);

  RETURN yield;
END;
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Solve: "bad guess(es)" error... - salvomic - 05-30-2015, 11:16 PM
RE: Solve: "bad guess(es)" error... - DrD - 05-31-2015 10:31 AM



User(s) browsing this thread: 1 Guest(s)