Skip to content

Yurie/Math

Math utilities.

Index

  • indexize[var_,index_] - join the variable and index(s) into a symbol.

    This is basically ToExpression[ToString[var_]<>ToString[index_]], but treating Null as an empty string.

    Example

    indexize[z,1]
    
    Out[] = z1
    
  • indexify - join the variable(s) and index(s) into a sequence of symbols.

    Example

    indexify[{z,zb},1,2]
    
    Out[] = Sequence[z1,zb1,z2,zb2]
    
  • indexSplit[vars__|{vars__}][expr_] - split symbols into indexed variables in the expression.

    Example

    z1+z2//indexSplit[z]
    
    Out[] = z[1]+z[2]
    
    • "IndexPosition"->Construct - controls the format of indexed vairables.

      The supported values are

      • Construct
      • Subscript
      • Superscript

      Example

      z1+z2//indexSplit[z,"IndexPosition"->Subscript]
      
      Out[] = Subscript[z,1]+Subscript[z,2]
      
    • "IndexType"->All - controls the pattern of indices, and resolves possible conflicts between variable and index.

      The supported values are

      • All
      • "PositiveInteger"
      • "PositiveIntegerOrSingleLetter"
      • "PositiveIntegerOrGreekLetter"
      • "NaturalNumber"
      • "NaturalNumberOrSingleLetter"
      • "NaturalNumberOrGreekLetter"
      • _Symbol - any function for string pattern matching

      Example

      zb1//indexSplit[{z,zb},"IndexType"->"PositiveInteger"]
      
      Out[] = zb[1]
      
      zb1//indexSplit[{z,zb}]
      
      Out[] = z[b1]
      
  • indexJoin[vars__|{vars__}][expr_] - join indexed variables into symbols in the expression.

    Example

    z[1]+z[2]//indexJoin[z]
    
    Out[] = z1+z2
    
    • The options are the same as indexSplit.