User Tools

Site Tools


gibson:teaching:spring-2018:math445:lecture:arithmetic

This is an old revision of the document!


A PCRE internal error occured. This might be caused by a faulty plugin

===== Math 445 Mathematics and Applications in Matlab ===== Four goals - learn numerical programming - learn applied mathematics - explore applications - think about science and society - grow in speaking, writing, reading, maturity ====Command line (REPL)==== * Read an expression * Evaluate it * Print the result * Loop back --do it again! example <code matlab> >> 4 + 5 ans = 9 >> </code> ====Arithmetic operators==== + plus - minus * times / divide \ divide ^ power % comment examples <code matlab> >> 4^3 ans = 64 >> 4/3 ans = 1.33333 >> 4\3 ans = 0.75 >> 4+3 % write a comment here, Matlab will ignore it ans = 12 </code> ====Precedence==== <code> ^ first * / \ next + - last </code> examples <code> >> 2*5^2-3/4+1 ans = 50.25 >> (2*5)^2-3/(4+1) ans = 99.4000 </code> ====Special numbers==== pi 3.1415926... inf infinity NaN not a number i imaginary unit j imaginary unit for electrical eningeers! >> sin(pi) ans = 1.2246e-16 % wha...? What does this mean? This is shorthand for scientific notation 1.2246e-16 means 1.2246 x 10^(-16) Why is sin(pi) not zero? >> 0.4 - 0.3 - 0.1 ====Variables==== >> x = 4 % assign value of 4 to variable x x = 4 >> y = 3 % assign value of 3 to variable x y = 3 >> x*y % evaluate x times y ans = 12 >> ans % variable ans is value of last expression ans = 12 ====Evaluating expressions==== >> x = 3; >> y = x^2 - 2*x + 5 y = 8 >> x = 1; >> y = x^2 - 2*x + 5 y = 4 ==== basic math functions ==== sin, cos, tan, sec, csc, cot, asin, acos, atan, exp, log, log10, abs, sqrt, factorial, mod ====Workspace commands==== help ; supress format compact format loose format long format short diary on diary off who whos clear x clear all ls or dir pwd cd

gibson/teaching/spring-2018/math445/lecture/arithmetic.1516743340.txt.gz · Last modified: 2018/01/23 13:35 by gibson