Tuesday, September 28, 2010

UPDATE: Sage vs Mathematica

Sage is the winner.  Period.  It accomplishes the same thing that Mathematica does except it does so for free.  Sage is also open source.  It appears to integrate nicely with python (as does the Arduino).  Since I have experience using Tkinter to build GUIs in python, we should be able to get the desktop application complete on schedule.

Below is a graph I generated using Sage.  The data was generated using the (updated) java script I wrote before.  Just as in Mathematica, the graph is interactive and can be rotated with the mouse.



Below is the updated java code that generates a sample dataset for Mathematica and Sage.

import java.util.Random;
public class datamake {

    public static void main(String[] args) {
        Random gen = new Random();
        int rdm = 0;
        String mathematica = "";
        String sage ="";
        
        mathematica += ("ListSurfacePlot3D[{"); 
        sage += ("list_plot3d([");
        for(int i = 0; i < 10; i++){
            for(int j = 0; j < 10; j++){
                if(gen.nextInt() %4 == 0){
               rdm = gen.nextInt(5);
               mathematica += ("{" + i + "," + j + "," + rdm + "},");
               sage += "(" + i + "," + j + "," + rdm + "),";
                }
            }
        }
        mathematica = mathematica.substring(0,mathematica.length()-1);
        mathematica += ("}]");
        
        sage = sage.substring(0, sage.length()-1);
        sage += "])";
        
        
        System.out.println(mathematica);       
        System.out.println(sage);
    }

No comments:

Post a Comment