1 / 14

Introduction to Computing for Mathematics and Statistics Winter 2011 Course

This course provides an introduction to computing principles and techniques for mathematics and statistics students. Topics include programming, plotting graphs, solving equations, and writing functions.

ryanharris
Download Presentation

Introduction to Computing for Mathematics and Statistics Winter 2011 Course

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 This week’s lab will not be graded. You will work individually. You can finish lab 1 without penalty next week. Thereafter, you will have to finish each lab within the lab hours. It is your responsibility to know which lab section you are enrolled in and show up at the correct time.

  3. Math/CSE 1560, Winter 2011 Last class 1. Some programming principles and • 2. Plotting graphs. • Next: Solving equations, writing your own functions.

  4. Math/CSE 1560, Winter 2011 A better plot > plot(15+cos(x),x=0..4*Pi,labels = [“day”,”price”],title = “Daily price of Maple syrup”);

  5. Math/CSE 1560, Winter 2011 More plot options • color=“Red” • thickness = 3 • More at ?plot[options]

  6. Math/CSE 1560, Winter 2011 More on solving equations > solve(3*x+2 = 11,x); Check your answer: > eval(3*x+2,x=3) OR > evalb(eval(3*x+2=11,x=3));

  7. Math/CSE 1560, Winter 2011 More on solving equations - 2 > solve(x^2-2 = 0,x); Simplify: > evalf(%) ; BUT > simplify(%) does not work!

  8. Math/CSE 1560, Winter 2011 More on solving equations - 3 > solve({3*x-2*y = 0,4*x+5*y=10},{x,y}); Simplify: > evalf(%) ; Notice: solve(x^5-x^3=1,x); RootOf(_Z^5-_Z^3-1, index = 1), RootOf(_Z^5-_Z^3-1, index = 2), RootOf(_Z^5-_Z^3-1, index = 3), RootOf(_Z^5-_Z^3-1, index = 4), RootOf(_Z^5-_Z^3-1, index = 5) solve(x^5-x^3=1.0,x); 1.236505703, .3407948662+.7854231030*I, -.9590477179+.4283659562*I, -.9590477179-.4283659562*I, .3407948662-.7854231030*I

  9. Math/CSE 1560, Winter 2011 More on solving equations - 4 In general use fsolve for numerical solutions. fsolve(x^5-x^3=1,x); 1.236505703 fsolve(x^5-x^3=1,x,complex,maxsols=5); To access individual solutions: Sols:= fsolve(x^5-x^3=1,x,complex,maxsols=5); Sols[3];

  10. Math/CSE 1560, Winter 2011 Steps for solving equations • > solve(exp(x^2)-50*x^2+3*x = 0, x); • Warning, solutions may have been lost • > solve(exp(x^2)-50*x^2+3*x = 0., x); • Warning, solutions may have been lost • > fsolve(exp(x^2)-50*x^2+3*x = 0, x); • -0.1154942111

  11. Math/CSE 1560, Winter 2011 Solutions within a range > fsolve(sin(x)-x=0,x,-Pi..Pi); Can do the same for solving several equations simultaneously.

  12. Math/CSE 1560, Winter 2011 Programming principle • Modular development • Reasons: • Code re-use • Develop, debug in isolation • Divide complex task into manageable pieces • A change in this module can be made without any other changes in other parts of the program.

  13. Math/CSE 1560, Winter 2011 Simple functions • f:= x->x^2+x+1; • Try f(2),f(x+1),f(f(x)) • f:= (x,y)->x^2+y^2;

  14. Math/CSE 1560, Winter 2011 A piecewise defined function • Math: • H(x) = 1, if x>0 • = 0 if x <=0 • Maple: • h:= x->piecewise(x>0,1,x<=0,0);

More Related