Techniques for Improving Performance

For most symbolic and numeric computation tasks, MuPAD® implements the fastest and most reliable currently known algorithms. Among these algorithms, the system always tries to find the best algorithm for your particular computation task. Often, the system also allows you to choose an algorithm explicitly or implicitly. For example, you can create a sequence by using the sequence generator $ or the for loop. Also, you can choose particular solvers, and simplification functions. Such choices can affect the performance of computations.

These techniques can accelerate your computations in MuPAD:

  • Use built-in MuPAD data types and functions when possible. Typically, these functions are optimized to handle your computation tasks faster and smoother.

  • Set assumptions on parameters when possible. Use the assumptions of variables sparingly or avoid them completely. For details about how assumptions affect performance, see When to Use Assumptions.

  • Call special solvers directly instead of using general solvers. If you can determine the type of an equation or system that you want to solve, calling the special solver for that equation or system type is more efficient. See Choosing a Solver.

  • Call numeric solvers directly if you know that a particular problem cannot be solved symbolically. This technique has a significant disadvantage: for nonpolynomial equations numeric solvers return only the first solution that they find.

  • Try using options. Many MuPAD functions accept options that let the system reduce computation efforts. For information about the options of a particular MuPAD function, see the "Options" section of the function help page.

  • Limit complexity of the expressions that you use.

  • Use shorter data structures when possible. For example, converting a sequence with 106 entries to a list takes longer than converting 1000 sequences with 1000 entries each.

  • Avoid creating large symbolic matrices and dense matrices when possible. For details about improving performance when working with matrices, see Using Sparse and Dense Matrices.

  • Avoid using for loops to create a sequence, a flat list, a string and similar data structures by appending new entries. Instead, use the sequence generator $.

  • Use for loops as outer loops when creating deep nested structures. Use the sequence generator $ for inner loops.

  • Use the remember mechanism if you call a procedure with the same arguments more than once. The remember mechanism lets you avoid unnecessary reevaluations. See Remember Mechanism. At the same time, avoid using the remember mechanism for nonrecurring procedure calls, especially if the arguments are numerical.

  • Avoid storing lots of data in the history table. If you suspect that the history table uses a significant amount of memory, clear the history table or reset the engine. For information about the history table, see History Mechanism.

  • Avoid running large background processes, including additional MuPAD sessions, at the same time as you execute code in MuPAD.

Was this topic helpful?