Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - Nosferatu Arucard 1983

Pages: [1]
This code belongs to one of my programs that I created  during my Ph.D. and are an Algebraic Parser library which enable the user input any algebraic expression and return a numerical value.  O.O

My implementation supports numbers in standard or scientific notation, 16 functions (12 trigonometric and 4 exponential/logarithmic), and also support variable assignments (it can store values on main memory  O.O)

The program use the wxWidgets framework, and the string manipulation uses the internal wxString type, which are more powerful than the STL library. Only the STL <cmath> was used to handle the arithmetic calculations.

The testing program is a kind of scientific calculator, although some buttons don't work as expect as the real job here was to test the new parser library for a PIXE program dedicated to handle nuclear stoichiometry by gamma ray yields  >:D

- To use the application, just fill any numerical expression and hit the "Return" button, the result will pop up on a Message Box.

 The program should evaluate some expressions like:
 To give the result: 7780.602815

 And using the variable feature, it can parse expressions like the following one:
 pi = 2*acos(0) , x = 2 * pi , a = 1 , b = a + 5 / sqrt(pi) : cos(x) + a*b
 Returning: 4.820948

 If you make a mistake, an error message will be present by a pop up window....
 pi = 2*acos(0) , x = 2 * pie , a = 1 , b = a + 5 / sqrt(pi) : cos(x) + a*b
 Giving the message:
 Declaration Error: Undefined Variable!

 - The algorithm I implemented is basically a sequence of three major steps:
 1. Lexical parsing, using an algorithm that somehow is partially my own invention. It uses some tricks to handle the parsing of numbers in scientific notation, and classifies the new tokens against a list of built-in words. On final, the original string are converted by a vector of tokens.
 2. The Shunting-Yard algorithm that convert the previous list of tokens to a postfix notation, while store any variables to a variable vector and checks if are correctly defined, and make the firsts syntax checks. Any error, like the previous step, will stop all process and displays the adequate error message.
 3. The postfix calculator, with some syntax checks, is the last step of whole process. Any arithmetic evaluation are done on this step, and if everything are correct, it will return the final result.

 The source code was bundled on the attachments, and the parser algorithm is implemented on CalculatorLibrary.  :)

First of all, until recently wasn't so easy to install a Linux Distro on unrooted Android tablets, since any viable solution requires root privileges to run some libraries.
After several working of some hackers, now is possible to try Debian or Fedora on Android tablets without rooting (and avoiding a headache is something bricks the tablet).
The most complete one is GnuRoot, which enables to install Debian Wheezy, Fedora Remix or Gentoo, but requires a second application for X11 Window Server and some elementary hacking.  ;D
(like this: start XSDL app, and on GNuRoot's Terminal app just type:
$ DISPLAY= startxfce4
To start the XFCE 4 Desktop Environment, if you install it first  ;D )

Later, a app to install Wheezy with XFCE4 was launched as Debian noroot on Google Play, but you can install the apk package from SourceFourge project page. The app install's automagically th base system and starts directly to Desktop mode. Other advange of this project is the fact the Debian's version are based on the armhf version, instend the armel version on GnuRoot side.  :)

Now, since Mathematica was ported to Linux ARM, and launched on Raspbian Distro (based on armhf Debian Wheezy), I tried the installation of Mathematica 10 on a Tegra 3 Android tablet running the Debian noroot virtual machine application. After a little care of installing Java and some Fortran libraries from Wheezy Backports repo, the Mathematica starts, but hangs when the Wolfram logo pop up on screen, and display "initializing Kernel", or something else.  >:(
Running Mathematica from Terminal don't show any errors. The wolfram utility runs on Terminal and asks a license key  :( .
Also, trying to run the Console version of Mathematica (mathkernel) means nothing, since it's absent.  :/
No matter I try, I need to kill Mathematica to resume normal working.

Other software like JDownloader, LibreOffice, PeaZip, Qemu User i386 emulator to run some x86 software, LibreCad, Qt Creator installs and runs nicelly, turning an Android tablet on a full blown Linux laptop computer (except kernel modules, low level hardware acess since it is not acessible form a chrooted environment).

So, it is a bug of software or a hack is needed to run Mathematica on a generic ARM computer ? I don't think Wolfram was put a hardcoded routine check to verity the ARM features to verify if someone try to run Mathematica on other ARM computer than a Raspberry Pi. Even this error are easilly documented on x86 computers as well.

Math and Science / Maxima on Android
« on: January 07, 2013, 11:38:24 am »
Since I like the Maxima CAS, I decided to open a discussion thread about the Android port of this software.

This system can be installed in every Android device (even the lowest grade smartphones), and requires about 90 Mb of storage space to install (32 Mb in internal storage is mandatory, the other stuff can be installed in SD card).
 Just open Google Play on your Android smartphone/tablet and search for "Maxima on Android".

 Once the APK is sucefully installed, the program asks first the location of data files (about 60 Mb), and then just wait (low Android devices can take up a minute to install everything) to install the LISP interpreter, all Maxima code written in LISP, the Gnuplot renderer, and finally the full Maxima Manual (you need to read this first!  ;)).
 When all stuff is installed, the program restarts and prompt you to a single command line box (the input area), and a virtual page to display the results and other technical information. (Math formulas are rendered with a built-in LaTeX parser).

 Using the Menu button, you can open the Maxima Manual and read all stuff (you can even program in Maxima  O.O) before you try, but I will take a quick guide to use.

 All comands sentences should end with a semicolon (;), or a syntax error will be prompted.
 E.g: "2+6;" will give  "8" , in output area.
 Since Maxima was written in LISP, the main syntax obeys the structures of lists and sentences (but you don't need to use the RPN format)

 Maxima suports all trigonometric functions, exponentials and natural logarithms. Some special functions like Riemann's zeta function, gamma function, Bessel functions are fully supported.

 Maxima can calculate many simbolic integrals, just use the primitive command: "integrate"
 e.g:  integrate(x^2,x);

 Defined integrals are normally calculated using the Barrow's Rule, but in some situations some advanced technics like the [wikipedia]Residue_theorem[/wikipedia] are used, or in some special cases, special functions are used.

 e.g: Maxima cannot evaluate the following integral:

(It will retirn the result unevaluted, since it don't knows any anti-derivative of the sample function written above):

But if the limits of integration are all real line (minus infinity to plus infinity), and the poles of function are imaginary numbers, then the Residues Theorem are used by Maxima, and the integral are calculated:

 (The  result are:)

 Maxima knows some constants like the Euler's number (%e), the Pi (%pi), the imaginary constant (%i) and the Euler-Mascheroni constant (%gamma), and all is signed by the % prefix to avoid confusion.

 Other example of integration calculus involve some adicional parameter that Maxima can ask during evalution:
 e.g: integrate(cos(x^n),x,0,inf);

 Maxima don't know the domain of n, so it ask if n is positive or negative, and you need to answer in input box (positive;).
 After a couple of questions, Maxima outputs the result:

 To calculate derivatives, just use the diff operator:
e.g: diff(sin(x),x);
output: cos(x)

 Maxima can even calculate derivatives of special functions:


 I hope you enjoy this simple introduction...  :)

I have a some time ago this simple question, since the Nspire was able not only to emulate the TI-84 and TI-89 (experimental and lost source code), but also the Game Boy Color and Game Boy Advance. (The last one requires a bit of CPU power to emulate this Nintendo console.)
Now, I ask if a Neo Geo emulator is possible in Nspire, even the main constraint is the last games released to this arcade system: The Metal Slug 3 and 4 and King of Fighters 2003 require about 80 Mb of SSD space (and the CX had about 100 Mb  :P)

The TI-84 and TI-89 emulators for Nspire is basically a Z80 and M68k CPU binary translators, and the Neo Geo Arcade System is basically a custom arcade hardware based with both those CPU.  :P
 The first usable emulator for NeoGeo was the NeoRageX which only need a low end Pentium MMX (166 Mhz) to emulate, but a Pentium II runs better. The ARM CPU of NSpire may be a little weak to emulate the Neo Geo System, but even so, I give this crazy idea to the comunity: (try) to build a Neo Geo emulator for Nspire (with or without Linux mode)  :D

Let's share one of my ideas about a possible handled calculator, or at last a dedicated Linux distro for the next generation of low-cost micro-computers like the Raspberry Pi, to handle a nice math package for engineering and low-cost numerical power.  ;)

A say a Linux Distro, just because an engineer would use a full blown computer to numerical, symbolic e physics calculations, not a low-end calculator. Hardware modders would be glad to install a optimized software to turn our $25 ARM processor into a high-end calculator via HDMI port  ^-^ (like the Raspberry Pi). If this Linux distro was really stable and easy to port between platforms, then create a more "official" calculator-like hardware project will be much easier to do.

 To merge two possible trends, I will descrive the core fundation of a Linux distro for calculators (or "calculators"  ::)) which I call:
 Maxima OS

The Maxima OS is basically a modern implementation of one of best open-source CAS packages ever made: The Maxima.
 Maxima is written with GNU LISP, and so far is most powerfull CAS library in FOSS, which the most recent version is 5.28 and have an official git and a GNU/GPL license (which means all changes of source code should be forward to Maxima Git).
 The raw mode operation of Maxima is by a CLI interface, and normally don't load all additional packages unless it's added in config file.
 Modern day approaches use an HTML shell to create a more easy acess to the Maxima runtime core, and requires additional programs to do some tasks (like graph plotting).  :)

 The Maxima OS project may use a browser like application to create a modern interface to Maxima core, and a more pleasent GUI to operate the software (many GUI Maxima use a very simple browser approach).
 When I made some make-ups of the Maxima Shell GUI, the result was gradually become equall to the Google Chrome OS  >:D.
 The reason is because I wanted to set up a small browser with XML and Javascript capabilities to build the applications.
 Add a tabbed interface with some buttons and it gets a Google Chrome clone!
 (And find some capable to implement is own ideas  :P).

 The browser-like shell model is because of my Android and Chrome experience (by user rating), and because GUI Maxima uses normally a browser to the interface. (And to create a more integrated environment, specially to normal tasks).

 And the other reason to use this approach is because my curiosity with the new graphic engine called Wayland.
 The underlaying operating system os Maxima OS is a Linux 3.6.x, 3.7.x, ... kernel with the Wayland and Weston compositor, which fits nicelly with low powered ARM devices. (Cuts the old legacy code from X Window Server).
 In top of Linux, Wayland and other libraries like SDL, hardware drivers, and other stuff, the Maxima and the Browser Shell run on top of it. The Maxima OS is designed to run on low-end ARM SoC (requires a ARMv6 with OpenGL ES support), like the CPU/GPU used on Raspberry Pi, or simply on QEMU.

 Now the drawbacks: The Google Chrome was sucefully ported to pure Weston composed with the lite Aura Toolkit, but is an overkill (and a potential sue problem) to use a full-blown browser to run on a "calculator"  >:D.
 It's possible to use a more lightheight browser (restricted to XML/HTML/Javascript), but the main problem of Weston composer (without X) is the lack of good general toolkits to program applications. (GTK+ in vanilla Wayland is a disaster, only QT 5.0 is 99% Weston compilant).
 And so far, no one was created a full desktop environment to vanilla Wayland/Weston composer. (However, a full Desktop on a small ARM computer is a total overkill). With some imagination is possible to build a menu to launch the applications, but I prefer the community to solve the User Interface Problem.

 In summary, the challange that I will propose is to create the Maxima OS with this simple requests (my lack of programing skills don't means that I can't help with this project, since I could test the builds or wrote the on-line documentation  ;D):

To create a Alpha stage distro:
ARM Linux Kernel 3.6 (so far)
Add the minimum kernel modules, like USB, LCD, audio, video, NTFS support, as necessary.
Wayland/Weston 1.0 vanilla
Maxima 5.28 (or newer)
SDL and QT toolkits
Create a simple browser to make the new shell to Maxima (XML/JS), and also the on-line manual reference (like XMaxima), in tabbed interface style.
Implement some simple Weston programs (The Terminal emulator is, apart the browser, the only real usefull program in graphic mode).
The browser itself can be a model to JavaScripts widgets  O.O (like a basic numeric calculator)

The "dreamed" calculator would use a SoC like the model used in Paspberry Pi (the RAM, CPU, GPU, DSP was integrated in the same chip), with analog audio out, standard USB port (1x or 2x), and a 16-bit 640*480 colour LCD screen.

But, since is a too wishfull thinking, the project should use or a Rapsberry Pi or any low-end ARM machine capable to boot any unsigned operating system. However, the best workable environment to a alpha stage Linux OS is to use a regular PC with QEMU. (I have some experience to build a QEMU virtual machine).
 Just configure a ARM based machine on QEMU and boot the virtual disk with the Maxima OS.

 The dice is rolled! There is someone on this calculator-friendly forum capable to archive this dream ? :D
(And by the way, it's best to open a git server or SourceForge project to host the source code and binaries to the Maxima OS project!)

Since the infinity sum of sin(x) from x=0 to infinity (sin(0) + sin(1)+ ...) don't converge, we can use the Abel-Plana formula to calculate a renormalized sum of the former divergent sum:

sum(f(t),t=0 to infinity)  =  f(0)/2  + integrate(f(t),t,0,infinity) - i * integrate((f(i*t) - f(-i*t))/(exp(2*pi*t)-1) , t, 0 ,infinity)

 But today I only show the problem,  waiting to someone to try solve this ridle.  ;)

Edit: A minor fix to the result.  :P

Introduce Yourself! / Greetings from Hellsing
« on: November 08, 2012, 09:39:49 pm »
Hello! Greetings from Portugal and the major Faculty of Engineering from Lisbon (IST), when I graduated in Physics and some extra stuff in Mathematics.  :)
 My pen name is a very famous anime vampire protagonist: Arucard (or Alucard), and since then every forum or discussion board I use this pseudonym.

 Since this forum is a general calculator/mathematic software discussion, I decided to join to share my projects which alone I don't have any chance to make it real.
 The main crazy project that I have about ten years dream it :P was to create the first color based calculator handled, even before the PRIZM come to the shops! Even this crazy stuff was to be impossible to achive with my non-existent resources, some of my thoughts was writing in a white-paper that I will publish in another thread.
 Since my graduate fields in Physics and Mathematics, I will publish some funny threads to share my knowledges.

 p.s. Sorry to my biased english grammar.

Pages: [1]