Editing Formulas
Prev
Next

Editing Formulas

The Edit->Edit Formula String allows the user to edit the ASCII formulas that have been copied from other applications, such as Scilab, and transform them directly into mathematical type. An example will make this clear. Below is a screenshot of INRIA Scilab.



Copy and paste the text beginning with x*sin(30*x) into the formula editor as shown below:



If you click on OK, the editor will complain about aborted parsing. It cannot recognize one of the symbols in the formula. The displayed formula would show that the Pi symbol is not correctly rendered. This means that the % must be deleted. Do this and KFormula will render the mathematical font properly, as shown below.



The formula editor will accept most C language mathematical expressions, like the formulas from a Runge-Kutta program below:

void derives(float x, float y[], float dydx[])
{
 dydx[1] = y[2];
 dydx[2] = -0.8*x*y[2] - sin(x)*y[1];
}

Here dydx[1] is the first order derivative and dydx[2] is the second order derivative. After copying the formula, you will have to edit the derivatives with KFormula. Here is how it is done. First copy and paste the bottom expression into the formula editor.



Next remove the [ ], leaving just y's.



Now click OK and place the cursor by a y and delete it. Insert the appropriate symbols as shown below.



Not every expression that KFormula is capable of translates into a valid C expression. For example the superscript expression:



is displayed as ()**(), which is not a valid C statement for exponentiation. Similarly the 1 by 2 matrix displays as ()/(). This is not a valid array in C.

Prev
Next
Home


Would you like to comment or contribute an update to this page?
Send feedback to the TDE Development Team