IBM ILOG Solver User's Manual > More on Modeling > Using Constrained Floating-Point Variables: Modeling Equations > Using predefined functions with floating-point variables

Concert Technology provides many predefined functions to use with floating-point variables, such as IloPower and IloExponent. To demonstrate their use, let's code the equation: x + x3 + ex = 10.

#include <ilsolver/ilosolverfloat.h>

ILOSTLBEGIN

int main(){
  IloEnv env;
  try {
    IloModel model(env);

    IloNumVar x (env, 1, 10);  // Declaring the variable

    // Adding the constraint to the model
    model.add(x + IloPower(x, 3L) + IloExponent(x) == 10.);

    IloSolver solver(model);
    
    if (solver.solve())
      solver.out() << "x = " << solver.getValue(x) << endl;
    solver.printInformation();
  }
  catch (IloException& ex) {
    cout << "Error: " << ex << endl;
  }
  env.end();
  return 0;
}

When executing this program, you should get the following output.

x = 1.55113

The complete program is available online in the YourSolverHome/examples/src/equation.cpp file.