Math Widget is an interactive input method, enabling users to smoothly handwrite mathematical operations and equations, which can then be typeset and solved. Based on MyScript Math SDK, it displays its features in a user-friendly interface.

Math Widget is designed to ensure a natural, handwriting-based HMI with real-time recognition and ink editing gestures. It also offers all the calculation features of a common scientific calculator, including exponential and trigonometric functions.

Use cases

The below use cases are only examples of applications where Math Widget has been used, sometimes with additional features. Note that all available features are listed in the API.

MyScript Calculator

MyScript Calculator is an handwriting calculator based on MyScript Math. In this scenario, the user handwrites mathematical operations and equations. Handwritten input is converted into a digital text formula. The widget can also solve simple arithmetic and trigonometric formulas, returning a calculated result. The content of the displays can be exported as an image or as a MathML or LaTeX string.

MyScript MathPad

MyScript MathPad is a handwriting LaTeX generator based on MyScript Math. It allows you to handwrite your equations and mathematical expressions and convert them for easy sharing.


Real-time recognition of symbols and rules
Real-time recognition of mathematical rules and more than 200 mathematical symbols and characters.

Typeset rendering
Captured handwritten equations can be rendered to typeset equations in real-time. Rendering can be customized (font, color, background, etc.).

Editing gestures
Correction (strikethrough, scratch-out) can be applied on both original handwritten text and typeset text. They can also be deactivated if needed. Undo/redo features are supported.

LaTeX, MathML, image and text results
Results are available as LaTeX, MathML, image and text.

Solver activation
Entered equations can be solved and question marks are supported as unknown variables. Rounding and truncation options are available.

Save and restore
Save and restore your equation in MyScript Math format.

Supported symbols

See below a non-exhaustive list of supported symbols.

It is also possible to create a custom grammar resource, by constraining the recognition for particular use cases (integral calculus, vector calculus, finite element calculus, etc.). For more information, see the Developer tools page.

Type of item  Items
Letters (Latin alphabet) a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Digits 0 1 2 3 4 5 6 7 8 9
Mathematical symbols (including operators)  € $ £ ¥ ₩ ¢ ( ) < > [ ] { }  ! # % & ? @ / \ | ∥ © ∂∅ ∇ ∞ ℂ ℕ ℚ ℝ ℤ + - ± × ÷ * ∘ · = ‘ , .  : ; _ ← ↑ → ↓ ↔ ↕ ↖ ↗ ↘ ↙⇐ ⇑ ⇒ ⇓ ⇔ ⇕ ∀ ∃ ∄ ∈ ∉ ∋ ∌ ∪ ∩ ⊂ ⊃ ⊄ ⊅ ∼ ≃ ≈ ≠ ≡ ≢ ≤ ≥ ≪ ≫ ∝ ∠ ∏ ∑ ∫ ∫∫ ∫∫∫ ∮ ∯ ∰ ∧ √l ⊕ ⊗ ⊖ ⊙ ¬Ψℑℜℓ↼⇀↽⇁⇋⇌∐∦≄≅≆≇≉≮≯≰≱⋉⋊⋮⌈⌉ ⌊⌋□ △ ⟦ ⟧ ⦞ 𝔻 ⫻
Greek symbols frequently used in mathematics Γ Δ Ω α β γ δ ε η θ λ ν π ρ σ τ φ χ ψ ω ϕ µ
Mathematical terms sin cos tan sinh cosh tanh arcsin arccos arctan cot coth min max arg argmin argmax inf sup lim liminf limsup ln log dx dy dz dt
International convention units (weight, length, frequency, luminosity, dosage, pressure, etc.) km hm dam dm cm mm µm ha hl dal dl cl ml µl kg hg dag dg cg mg µg ms µs GHz MHz kHz Hz

Supported rules

Each grammar sets out a number of production rules for equations, namely:

Type of rule Written example Recognition
Horizontal pair 2x
Fence (2x)+3
Square root 388
Fraction 2x+4 5y-2 _____
Subscript x i
Subsuperscript i-1
Presuperscript 625 n
Overscript Σ n
Underscript Σ x=0
Underoverscript Σ j=1 n

Supported operations

The solver is activated only if the equation contains numbers and/or fractions and at least one of the following operators:

Input and output formats

It is possible to reload a result, using a symbol list or some binary data previously generated.

Math Widget also offers the possibility to export results in 5 different formats:

  • Math Widget symbol list
  • Binary data
  • Image
  • LaTeX

    \dfrac {-b\pm \sqrt {b^{2}-4ac}}{2a}

  • MathML
<math xmlns='http://www.w3.org/1998/Math/MathML'>
      <mo> - </mo>
      <mi> b </mi>
      <mo> &#x00B1; <!-- plus-minus sign --> </mo>
            <mi> b </mi>
            <mn> 2 </mn>
        <mo> - </mo>
        <mn> 4 </mn>
        <mi> a </mi>
        <mi> c </mi>
      <mn> 2 </mn>
      <mi> a </mi>

Display modes

No beautification

Characters stay handwritten until solving is activated manually, if needed. Text is then typeset and solved at the same time.


Characters are automatically typeset after a short delay, using standard math fonts or custom fonts. If needed, solving has to be activated manually.

Typeset and solve

Characters are typeset after a short delay, using standard math fonts or custom fonts. The whole operation is solved, provided that its characters are supported by the solver (see above).


Please make sure to use the latest version of Android Studio and have all Android tools and SDK (level 15 or up) installed and configured properly.

Step 1 - Download your Certificate

  1. Log in at https://atk.myscript.com.
  2. In the Applications tab, click Create application.
  3. Enter your application name and its description, then click Create.
  4. Click Open, then Create certificate.
  5. Enter the package name that can be found in AndroidManifest.xml and select the target environment, then click Create.
  6. Click on the .java download icon to download the corresponding certificate.
  7. Paste it in your project and start creating your app.
You need one certificate per application and per platform. You can integrate several widgets in one application.

Step 2 - Configure your Dependencies

  • In the build.gradle file of your project, add:
repositories {
    flatDir {
        // Location of your package's `libs` directory containing `*.aar` files.
        dirs 'path/to/libs'
  • In the dependencies section, add:
compile 'com.android.support:appcompat-v7:23.+'

compile(name: 'MyScript_ATK-Core-android-component', ext: 'aar')
compile(name: 'MyScript_ATK-Math-android-component', ext: 'aar')
compile(name: 'MyScript_ATK-MathWidget-android-widget', ext: 'aar')

Step 3 - Add Resources

Copy the assets directory from samples/MathWidgetSample/src/main into your project. It contains the following directories:

  • resources/math-ak.res,
  • resources/math-grm-standard.res,
  • conf/math.conf.
Resources are available for download on the Developer Portal. You can also customize your own resources: Check the Developer Tools page to discover how.

Step 4 - Add a Layout Resource

To integrate the Math Widget view, add the following snippet in your layout.


Step 5 - Start with Minimal Integration Code

An Internet connection is required to launch and run ATK applications. To authorize it, add the following line in the AndroidManifest.xml file:

<uses-permission android:name="android.permission.INTERNET" />
However, a 30-day grace period is offered, from the moment you first launch your application. A connection will then be mandatory.

Edit the MainActivity class:

public class MainActivity extends AppCompatActivity implements

  private static final String TAG = "MathDemo";

  private MathWidgetApi widget;

  protected void onCreate(Bundle savedInstanceState)


    widget = (MathWidgetApi) findViewById(R.id.math_widget);
    if (!widget.registerCertificate(MyCertificate.getBytes()))
      AlertDialog.Builder dlgAlert  = new AlertDialog.Builder(this);
      dlgAlert.setMessage("Please use a valid certificate.");
      dlgAlert.setTitle("Invalid certificate");
      dlgAlert.setPositiveButton("OK", new DialogInterface.OnClickListener()
        public void onClick(DialogInterface dialog, int which)
          //dismiss the dialog

    // Listen to widget events (see onConfigureEnd and onRecognitionEnd APIs)

    // references assets directly from the APK to avoid extraction in application
    // file system
    widget.addSearchDir("zip://" + getPackageCodePath() + "!/assets/conf");

    // The configuration is an asynchronous operation. Callbacks are provided to
    // monitor the beginning and end of the configuration process and update the UI
    // of the input method accordingly.
    // "math" references the conf/math/math.conf file in your assets.
    // "standard" references the configuration name in math.conf
    widget.configure("math", "standard");

  protected void onDestroy()

    // release widget's resources

  public void onConfigureBegin(MathWidgetApi widget)

  public void onConfigureEnd(MathWidgetApi widget, boolean success)
      Toast.makeText(getApplicationContext(), widget.getErrorString(), Toast.LENGTH_LONG).show();
      Log.e(TAG, "Unable to configure the Math Widget: " + widget.getErrorString());
    Toast.makeText(getApplicationContext(), "Math Widget Configured", Toast.LENGTH_SHORT).show();
      Log.d(TAG, "Math Widget configured!");

  public void onRecognitionBegin(MathWidgetApi widget)

  public void onRecognitionEnd(MathWidgetApi widget)
    Toast.makeText(getApplicationContext(), "Recognition update", Toast.LENGTH_SHORT).show();
      Log.d(TAG, "Math Widget recognition: " + widget.getResultAsText());


See the API documentation for Android.