Package jline.api.sym

Interface SymEngine

All Known Implementing Classes:
SageRestEngine

public interface SymEngine
Computer algebra operations LINE needs, as seen by the JAR.

Java has no computer algebra system, so every operation here is delegated to an external engine; SageRestEngine is the SageMath implementation and is resolved by SymEngines. Expressions cross the interface as plain ASCII infix strings, e.g. "2*x1 - 3*x2", which is the format SolverCTMC.symbolicGeneratorResult.getSymbolicEntry already produces.

Expression strings are not comparable across codebases: the symbol numbering x1..xE follows event enumeration order, and printed normal forms depend on the engine version. Compare by substituting values with eval(java.util.List<java.lang.String>, java.util.Map<java.lang.String, java.lang.Double>) and comparing numbers.

Copyright (c) 2012-2026, Imperial College London All rights reserved.
  • Method Details

    • name

      String name()
      Name of the backing engine, e.g. "sage".
    • isAvailable

      boolean isAvailable()
      True if the engine answers a health probe.
    • solveCTMC

      SymEngine.CTMCSolution solveCTMC(String[][] Q, List<String> symbols) throws IOException
      Symbolic stationary distribution of a CTMC, pi Q = 0 with sum(pi) = 1.
      Parameters:
      Q - generator entries as expression strings, row major
      symbols - the symbols appearing in Q, e.g. x1..xE
      Returns:
      the solution, with pi also split over a common denominator
      Throws:
      IOException - if the engine is unreachable or rejects the request
    • ctmcSensitivity

      SymEngine.Sensitivity ctmcSensitivity(String[][] Q, List<String> symbols, String theta, List<String> reward) throws IOException
      Exact parametric sensitivity of a steady-state reward.
      Parameters:
      Q - generator entries as expression strings, row major
      symbols - the symbols appearing in Q
      theta - the symbol to differentiate with respect to
      reward - reward rate per state, or null for the distribution alone
      Returns:
      the sensitivity of the distribution and, if a reward is given, of its mean
      Throws:
      IOException - if the engine is unreachable or rejects the request
    • simplify

      List<String> simplify(List<String> exprs, String form) throws IOException
      Rewrites expressions into a normal form.
      Parameters:
      exprs - the expressions
      form - one of simplify, factor, together, cancel, expand, latex
      Returns:
      the rewritten expressions, in the input order
      Throws:
      IOException - if the engine is unreachable or rejects the request
    • diff

      List<String> diff(List<String> exprs, String variable, int order) throws IOException
      Differentiates expressions.
      Parameters:
      exprs - the expressions
      variable - the differentiation variable
      order - the order of the derivative, at least 1
      Returns:
      the derivatives, in the input order
      Throws:
      IOException - if the engine is unreachable or rejects the request
    • eval

      double[] eval(List<String> exprs, Map<String,Double> assignment) throws IOException
      Substitutes values for symbols and evaluates.
      Parameters:
      exprs - the expressions
      assignment - value of each symbol
      Returns:
      the numeric values, NaN where a free symbol remains
      Throws:
      IOException - if the engine is unreachable or rejects the request
    • fluidODEs

      SymEngine.FluidODEs fluidODEs(List<String> rhs, List<String> vars, List<String> want) throws IOException
      Jacobian, LaTeX form and equilibria of a fluid vector field.
      Parameters:
      rhs - the right hand side of dx/dt, one expression per state variable
      vars - the state variable names
      want - any of jacobian, latex, equilibria
      Returns:
      the requested items
      Throws:
      IOException - if the engine is unreachable or rejects the request