Simple second grade equation solver – MathStudio Tutorial

Let’s start exploring the MathStudio Script Language with this first tutorial. In this article we are going to code a simple second grade equation solver.

Some days ago we released the beta of our Mathematical IDE, MathStudio, which allows you to develop your technical applications in a simple way.

Actually, MathStudio has a simple command that implements the Brent’s equation solver, but we won’t use that in this tutorial. We will let the user input the coefficients of the second grade equation one by one. To do that in MathStudio, we use the input command:

output Insert 'a' coefficient:
[a] = input
output Insert 'b' coefficient:
[b] = input
output Insert 'c' coefficient:
[c] = input

We now have all the coefficients declared. According to Maths theory, we have to calculate the delta (discriminant). Delta is defined as ∆=b^2-4*a*c, so:

[delta] = calc ({b})^2-4*({a})*({c})

Now, according to the algorithm to solve this kind of equations, we have two results: x = (-b±√∆)/2*a, so:

//First result
[x1] = calc (-({b}) + sqrt({delta}))/2*({a})
//Second result
[x2] = calc (-({b}) - sqrt({delta}))/2*({a})

All we have to do now is to printing the results on the screen:

output First result: {x1}
output Second result: {x2}

In order to prevent the script from returning NaN (Not a Number) for both the results if delta is minor than zero, we can put a goto mark before the pause command:

if {delta} < 0 then

output [Delta < 0] Cannot calculate solutions.
goto end




You can also plot the function graph associated to the equation if you want:

fdef f(x) = ({a})*x^2+({b})*x+({c})
plot "f"

This sample is included in the GoManga MathStudio installer and you can find it under C:\GoManga\MathStudio\Samples\ but you can also download from here.

Have fun!

MathStudio beta is available

We are proud to announce that, after several months of news blackout on Social Networks and Devlog, we are back to share our news with you. We’re hard working on both Insane Decay of Mind: The Sound of Silence and Not Another Platform Game.


Moreover, in the last month we worked on a little new project, too. Its name is GoManga MathStudio and it is a powerful Mathemathical IDE developed in C# that will allow you to write your complex maths application in a very simple way. In fact, MathStudio provides a very simple syntax for its commands making technical software development easier than ever. Also, it includes a parser which is able to solve coplex mathematichal expressions and it offers several built-in tools for mathematical analysis. MathStudio beta is now available for free and all you need is downloading it!

A MathStudio Screenshot

Isn’t it enough for you?
MathStudio allows you to write your own commands and extentions for the editor! You can do this implementing the MathStudio.Core.Plugin interface in your code. Under the main directory of MathStudio (C:\GoManga\MathStudio\Samples\Plugins), you can also find two examples of implementation. The first one, written in C#, is a plugin that allows you to use the sumf command; the second one, written in VisualBasic, is a UI implementation of the maths parser for the editor. Take a look of the API Documentation for more details. Please note that, according to End-User License Agreement provided with the MathStudio installer wizard, you are not allowed to redistribute MathStudio binaries and executables, even if you are using them for your plugin. The MathStudio DLLs are not required to be put in the Plugins directory.

Are you ready to start coding?

First of all you need to download and install the MathStudio executables. Then, start the MathStudio Editor and write the code below:

output Hello World!

This code is the so famous Hello World script written in the MathStudio Language. You can execute it by simply pressing the F5 button.

The code runned

Cool, isn’t it? Take a look to the quick reference to see how to code in the MathStudio Language. In the C:\GoManga\MathStudio\Samples directory, you can find several examples of code and we will provide new ones on this Devlog.

We can’t wait to see what you make with this powerful editor: feel free to send your code at

Download GoManga MathStudio for free!

Read GoManga MathStudio quick reference

Read GoManga MathStudio API documentation