Expression

public class Expression : NSObject

A helper class to parse and manipulate math expressions

  • The expression node that contains the expression

    Declaration

    Swift

    public var node: ExpressionNode
  • Creates an Expression with the string representation of an expression

    Declaration

    Swift

    public init(_ str: String) throws
  • Creates an Expression from \LaTeX

    Declaration

    Swift

    public init(latex: String) throws
  • Returns all the symbols from the expression.

    Useful when you want to get a list of possible parameters

    Declaration

    Swift

    public var symbols: [SymbolNode] { get }
  • Solve equation using Brent’s method

    In numerical analysis, Brent’s method is a root-finding algorithm combining the bisection method, the secant method and inverse quadratic interpolation. It has the reliability of bisection but it can be as quick as some of the less-reliable methods. The algorithm tries to use the potentially fast-converging secant method or inverse quadratic interpolation if possible, but it falls back to the more robust bisection method if necessary.

    Declaration

    Swift

    func singleSolve(for variable: String, in interval: (BigNumber, BigNumber), with precision: BigNumber = 10e-3) throws -> BigNumber

    Parameters

    variable

    For which variable we’re solving the equation. Example: "x"

    interval

    In which interval the solution is predicted to be. Example: (-1, 1)

    precision

    At which precision you want the solution. Example: 10e-3

  • Solve equation using Brent’s method

    It will go through the interval using precision and will estimate possible zeros location. Then will use Brent’s algorithm to find thoses solutions.

    In numerical analysis, Brent’s method is a root-finding algorithm combining the bisection method, the secant method and inverse quadratic interpolation. It has the reliability of bisection but it can be as quick as some of the less-reliable methods. The algorithm tries to use the potentially fast-converging secant method or inverse quadratic interpolation if possible, but it falls back to the more robust bisection method if necessary.

    Declaration

    Swift

    func solve(for variable: String, in interval: (BigNumber, BigNumber), at rate: BigNumber = 10e-1, with precision: BigNumber = 10e-3) throws -> [BigNumber]

    Parameters

    variable

    For which variable we’re solving the equation. Example: "x"

    interval

    In which interval the solution is predicted to be. Example: (-1, 1)

    precision

    At which precision you want the solution. Example: 10e-4