Home .NET C# character calculator

C# character calculator

by admin

I once needed a c# library that could do symbolic calculations (from time to time I add capabilities to one mathematical program).All sorts of source code can be found on the web in different languages, but something simpler and more understandable could not find.I noticed the Jasymca (Java Symbolic Calculator)

Task

To implement an analog of Mathcad’s odesolve block in SMath Studio program, we needed to solve equations with respect to derivatives.There are no special restrictions on the ODE system to be solved.What the user sets in relatively arbitrary form should be converted to a form suitable for numerical solution of ODE. It should look like this :
C# character calculator
I found it hard to use the features of c# here in the general case. I could use the help of a symbolic engine.

Converting sources

Looked at the source code of the applet. It doesn’t look too bad, but I need a Java to c# converter. At the time when I first started doing this I found one more or less working online resource, which I can’t remember now. It looks like it was a resource from Tangible Software Solutions, since the comments in the source code are similar to what their current converter does as a program.
All good, but one bad thing. Resource converted for free only limited size source. Really limited the number of lines. Very strange, I thought, and I compressed all the content in each file into one line. Then I converted the one line source code to c# equivalent for free and restored it to its normal form in Visual Studio using automatic formatting.

Finishing with a file

Needless to say, the automatic converter converts most of the form, but the content needs more work. At that point I realized that I obviously lacked the levels in both languages to solve all the compilation problems. As time went on, I was reading John Skeet. Comrade Skeet inspired determination.
While fighting for compilability, I had a kind word for the converter. It did almost all the tedious work. Only the mathematical part was left out in some points. It concerned a big JMath class. Converting double to hex representation and back was limited in some cases by the BitConverter.Int64BitsToDouble() method, which does not work with some unsigned long constants, for example -0 ( 0x8000000000000000 ). Here comrade Skeet came to the rescue again, and not without his help we managed to represent this value as 1.0 / double.NegativeInfinity. In general, this "infinitesimal" arithmetic still bothers me, because I’m not sure about the correct interpretation of what the author Jasymca had in mind.
After fixing some semantic bugs, replacing the handling of types and instances and adding a console interface, I managed to run this project. I’ve long wanted to see the inner workings of such symbolic programs. Symbolic C++ is one thing, but Java or C# is quite another. The entry threshold is much lower.
As of this writing, the calculator looks like this :
C# character calculator
The executable is available at repository Net 2.0 is required. There is a LinqBridge dependency to run Linq in .Net 2.0 (library attached there as well).
Works pretty much all of the documentation by the author of Jasymca. The exception is the work with graphics, i.e. the construction of function graphs. I think it would be easier to re-write this part than to port it. Not included functions that depend on third party libraries (LAPACK, etc.). Also some bugs are present which will be cleaned up in time.

Conclusion

This project was created for lovers of symbolic mathematics. If you want it can be brought to the library and used in your own projects, where you need a simple numeric or symbolic mathematics: working with complex numbers, integration, differentiation, solving equations, etc. Author Jasymca Positioned the program as a tutorial for those who want to create their own program that performs symbolic calculations :

Jasymca has been developed for teaching mathematics, especially to facilitate a fast and easy entrance to computer mathematics. One of the main obstacles are pocket calculators, which prevent many students from using computers for math. Pocket calculaters are cheap and portable, while CAS-programs are often expensive and always require at least a laptop to run. Jasymca is free software and runs on almost any system equipped with a microprocessor: from mobile phones and pdas to windows/linux/macos computers, even on game consoles or internet routers.

I hope that the c# version of the source code will be useful to you in some way.

Links

1. Jasymca (Java Symbolic Calculator)
2. Jasymca the source code (zip).
3. Jasymca 2.0 — Symbolic Calculator for Java (Manual, pdf)
4. Overview of similar Java libraries
5. Project repository

You may also like