Tuesday, April 16, 2013

Quadratic Equation Solver for Android

     Solving quadratic equations is actually very straightforward operation. However, a tool for doing all the operations for solving quadratic equation on behalf of you is very useful. My first android application is a quadratic equation solver and graph drawer called QuadE. QuadE simply asks for the quadratic equation parameters from the user. The parameters as you know are stated as below;
After user enters the parameters the tool calculate the roots. Actually there are two cases for the solution of the quadratic equation, the first is the real roots case the other is imaginary roots case. Consider the real root case, for the roots to be real the delta of the equation should be zero or positive. For this case the roots are real and the curve corresponding to quadratic equation intercepts the x axis. If delta of equation is positive, curve intercepts the x axis at two different points. If delta is zero , the real roots are coincide and there are only one root so that only one interception of x axis. The latter case is as I said imaginary roots case. If delta is negative, the roots are imaginary meaning that the curve corresponding to quadratic equation do not intercept the x axis at any point.Please note that the imaginary roots should be in a form that they should be their complex conjugates.

     The root calculation procedure is reviewed, now we can continue with the key part of the tool, curve drawing. Actually curve drawing is simple, the main idea underlying drawing the equation curve is simply apply all the points in the x axis and find the corresponding y axis coordinates that holds the quadratic equation. However, the challenging part is that what will be the x and y axis scales so that we can see all the critical points on the graph. To achieve this goal, showing all the critical points in the graph, we should determine all of the critical coordinates and determine a scale which is more than all of the critical values. The scale determination algorithm is as follows; 

- find the roots(if any) X1 and X2 
- give 0 to x and calculate f(0) , so that we can find y interception, Y.
- find the maximum or minimum value, take the derivative of the quadratic equation with respect to x and equate it to the zero. (this gives us the point that the slope is 0 which means max or min value) f'(x) = 2ax + b
- solve the 0 = 2ax + b to find Xext, and apply F(Xext) to find Yext.
- Now we have all of the critical values; X1, X2, Y, Xext, Yext.
- The scale should be a larger value than the maximum of critical values. For example scale can be 4 times larger than the maximum critical value, so that the user can see all of the critical points.

After finding the scale value, the other things are very easy, just divide the whole x axis by for example 2000 values and find the corresponding y values for them. After finding all of the coordinates simple connect the neighboor coordinates by a straight line. If we take enough coordinates for the curve, the straight line combinations will be seen as a smoothly changing curve. 

     My application can be freely downloaded from the android market with a name of Quadratic Equation Solve/Graph at an address of . Please rate the labor at android market and do not forget to leave comments for enhancement of further releases.

Download Quadratic Equation Solve/Graph / Android

Recommended to be run on

1 comment: