Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Programming and problem solving in C, Maxima, and Excel.

Similar presentations


Presentation on theme: "1 Programming and problem solving in C, Maxima, and Excel."— Presentation transcript:

1 1 Programming and problem solving in C, Maxima, and Excel

2 2 In an ideal world: When you had a problem, you could use whichever approach was most efficient: –Maxima (or other computer algebra system) –Excel (or other spreadsheet) –C (or other programming language)

3 3 In an ideal world: When you had a problem, you could use whichever approach was most efficient: –Maxima (or other computer algebra system) –Excel (or other spreadsheet) –C (or other programming language) Unfortunately, they do not interface together very well.

4 4 We’ll review some of the major issues in using these tools to solve scientific and engineering problems.

5 5 Programming and problem solving in Computer Algebra Systems

6 6 Maxima Written in LISP Most LISP implementations are written in C, but the C code can be hard to get to. Uses exact arithmetic on things like Has (effectively) unlimited precision for calculating with numbers. Has several interfaces to graphics. Runs on PC, Mac, Linux, UNIX Free

7 7 Other Computer Algebra Systems (Mathematica, Matlab, …) Most written in C, but the C code can be hard to get to. Uses exact arithmetic on things like Has (effectively) unlimited precision for calculating with numbers. Has several interfaces to graphics. Runs on PC, Linux, UNIX Rarer on Macs Not free

8 8 Advantages of Maxima An interpreted environment – type in a command and see the results immediately. Programs in Maxima are in the form of “notebook” files that show the steps in a problem’s solution. An editor lets you move the cursor to the place where there was a syntax error, correct the error and run the corrected command.

9 9 Programming and problem solving in spreadsheets

10 10 Excel Easy-to-use user interface Almost universally available Arithmetic is not precise Has simple, easy-to-use basic graphics. Uses the Microsoft visual family of languages, primarily Visual Basic, to create functions. Runs on PC, Mac Not free

11 11 Other spreadsheets (Open Office, Numbers, …) Easy-to-use user interface Almost universally available in some form Arithmetic is not precise Has simple, easy-to-use basic graphics. Often use a simple, embedded programming language to create functions. Open Office runs on PC, Mac, Linux, UNIX Numbers (for Mac) not free

12 12 Programming and problem solving in programming languages

13 13 Advantages of C A compiled language: programs will run very fast. Very powerful and flexible language, at least for those expert in it. The most common language for systems-level programming. One of the two most common languages (with FORTRAN) for programming on supercomputers. Many extensive libraries.

14 14 Advantages of C Commonly available: PCs, Macs, Linux, UNIX A free version of the Free Software Foundation’s gnu gcc compiler runs on nearly every platform. At Howard, the Microsoft Visual Studio environment is free to students for academic purposes. A language that is not likely to be completely out of date (still in use, with no likely successor on the horizon)

15 15 Disadvantages of C Requires a knowledge of an editor or complex IDE (Integrated Development Environment) Response to syntax errors is not instantaneous Response to semantic errors or errors in program logic is not instantaneous Syntax is complex and hard to understand I/O is not easy Some function names are odd and the syntax is not consistent

16 16 Using all these tools for problem solving

17 17 How do these tools communicate? It is theoretically to call many of these tools from the other. –For example: –Maxima programs call C functions –C programs call Maxima programs In practice, this is not the way it is done

18 18 Rarely used connections Call Maxima from C code int main() { … system( ”Maxima …”); } I have never seen this except in an online chat room

19 19 Rarely used connections Call C code from Maxima: ( with_stdout("_hist.out", for i:1 thru length(hist) do ( print(i,hist[i]))), system("xgraph -bar -brw.7 -nl < hist.out")); I have never seen this except in the Maxima manual – never seen it used Probably does not work on PCs or Macs

20 20 There may be some ways to format output to C syntax from Maxima www.rbt.his.u- fukui.ac.jp/~naniwa/pub/maxima/cform.lis p There is a fortran() function in Maxima to format output in FORTRAN style

21 21 Calling Excel is even harder No obvious way from Maxima No obvious way from C. So, how do we use more than one of these as part of a problem’s solution?

22 22 Calling Excel is even harder No obvious way from Maxima No obvious way from C. So, how do we use more than one of these as part of a problem’s solution? We decompose the problem into portions best solved on each type of tool (CAS, spreadsheet, programming language)

23 23 How is communication done? By sending data to files that each tool can read.


Download ppt "1 Programming and problem solving in C, Maxima, and Excel."

Similar presentations


Ads by Google