1 / 18

Introduction to Computing for Mathematics and Statistics Winter 2011

This course provides an overview of computer programming using Maple for mathematics and statistics. Topics include basic commands, syntax, and components of Maple, as well as programming principles.

tylerclark
Download Presentation

Introduction to Computing for Mathematics and Statistics Winter 2011

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Suprakash Datta datta@cse.yorku.ca Office: CSEB 3043 Phone: 416-736-2100 ext 77875 Course page: http://www.cse.yorku.ca/course/1560 CSE/Math 1560:Introduction to Computing for Mathematics and Statistics Winter 2011 Math/CSE 1560, Winter 2011

  2. Math/CSE 1560, Winter 2011 Announcements No class on Wednesday Labs will start this week. This week’s lab will be a lightweight one, with very little credit attached. Next week we will commence with more challenging assignments and more associated credit. Gauss lab is in Ross S 110, not 100 as given on the web page. Please give Maple and Moodle a trial run before the lab if possible.

  3. Math/CSE 1560, Winter 2011 Last class • Course overview • Different UI’s of Maple • Today: Basic Maple commands and syntax

  4. Math/CSE 1560, Winter 2011 Samples of Maple at work - 5 eclipse 190 % xmaple &

  5. Math/CSE 1560, Winter 2011 Samples of Maple at work - 6

  6. Samples of Maple at work - 7 Math/CSE 1560, Winter 2011

  7. Math/CSE 1560, Winter 2011 Using Maple • Starting and exiting • Getting help • Interrupting Maple • The restart command > a:=10; a := 10 > a; 10 > restart; > a; a

  8. Math/CSE 1560, Winter 2011 Maple components • Interface • Kernel • Basic functionality • Library • Basic library • Packages

  9. Math/CSE 1560, Winter 2011 Basic commands • > eval(Pi); • Pi • > evalf(Pi); • 3.141592654 • > evalf(Pi,30); 3.14159265358979323846264338328 • > Digits:=20; • Digits := 20 • > evalf(Pi); • 3.1415926535897932385 Specify precision What changed?

  10. Math/CSE 1560, Winter 2011 Remember help • > ?Digits • The Digits Environment Variable • Calling Sequence • Digits := n • Parameters • n - natural number • Description • - The Digits environment variable controls the number of digits that Maple uses when calculating with software floating-point numbers. • - The default value of Digits is 10. The value of Digits is changed by using the assignment operator. • ………………………………………….

  11. Math/CSE 1560, Winter 2011 Basic commands - 2 • > Pi_20:= evalf(Pi,20); • > evalf(sin(Pi)); • > evalf(sin(Pi_20)); • > %% - %; • -9 • 0.4102067615 10 Output suppressed to save space

  12. Math/CSE 1560, Winter 2011 Basic commands - 3 • > solve(x^2-1=0,x); • 1, -1 • > solve(x^4-1=0,x); • -1, 1, I, -I • > solve(x^3-1=0,x); • 1/2 1/2 • 1, - 1/2 + 1/2 I 3 , - 1/2 - 1/2 I 3 • > solve(11*x^4-9*x+17=0,x); • RootOf(%1, index = 1), RootOf(%1, index = 2), RootOf(%1, index = 3), • RootOf(%1, index = 4) • 4 • %1 := 11 _Z - 9 _Z + 17

  13. Math/CSE 1560, Winter 2011 Basic commands - 4 • > simplify(sqrt(4)+5); • 7 • > simplify((x+1)^2); • 2 • (x + 1) • > simplify((x+1)^2-1); • 2 • x + 2 x • > expand((x+1)^2); • 2 • x + 2 x + 1 • > factor((x+1)^2-1); • x (x + 2)

  14. Math/CSE 1560, Winter 2011 Basic commands - 5 • > expand((x+1)^(10)); • 10 9 8 7 6 5 4 3 2 • x + 10 x + 45 x + 120 x + 210 x + 252 x + 210 x + 120 x + 45 x + 10 x + 1 • > sort(x+1-x^2); • 2 • -x + x + 1 • > expand(sin(2*x)); • 2 sin(x) cos(x)

  15. Math/CSE 1560, Winter 2011 Basic operators • Arithmetic: +,-,*,/,^,mod • Logical: and,or,xor,not,implies • Relation: <,<=,>,>=,=,<> • Variable names: • Start with a letter • Letters, digits, or _ • Reserved words (e.g.: Pi, Digits,…) • Try ?reserved

  16. Math/CSE 1560, Winter 2011 More syntax • Brackets: • () : group expressions • [] : lists, vectors, matrices,… • {} : sets := vs = > my_eqn:=2*x=2; my_eqn := 2 x = 2 > solve(my_eqn,x); 1 > y:=%: > y; 1 Note the colon

  17. Math/CSE 1560, Winter 2011 More syntax - 2 Recall my_eqn:=2*x=2; • Manipulating equations • > rhs(my_eqn);lhs(my_eqn); • 2 • 2 x • Comments • Starts with “#” • Goes to the end of the line 2 commands on 1 line.

  18. Math/CSE 1560, Winter 2011 Programming principles • Variable names • Good mnemonic value • Low ambiguity • Comments • Meant to help the reader understand code • Tradeoff between verbosity and readability • Reader should not have to spend hours trying to figure out what the programmer wanted to do

More Related