


















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



















R.Sonnenfeld
Richard Sonnenfeld
R.Sonnenfeld Progress in Scientific Computing
Computers have improved by 4-6 orders of magnitude. It is foolish not to use the single most powerful tool that has arisen for this generation.
R.Sonnenfeld Types of problems we will tackle Motion with variable accelerations. Air-resistance and drag. Rocket motion. Center of mass and moment of inertia of asymmetrical objects. Orbital motion of planets.
R.Sonnenfeld Computer Languages Low-level: Machine Language – Actual binary codes Assembly code – Text abbreviations for same binary codes “High-level”: C – Higher-level instructions that still provide access to very low- level structures on the computer. The foundation of Linux/Unix. Fortran – The original language of scientific computing. Both these languages are from an era when computers were slow and overwhelmed by scientific requirements. They were designed to get maximum performance from weak hardware. Modern: Python and Java – Do everything C and Fortran do, often nearly as fast. Were written to make the programmer more efficient, not the computer. Code is extremely “portable”. Matlab – Matrix lab. Began as Fortran code in the 1970s. Is now another scripted high-level language enabling high programmer productivity.
R.Sonnenfeld
R.Sonnenfeld X=X+Y; AddA 452 001 100 101 010 001 100 101 010 001 100 101 010 Y X
R.Sonnenfeld How this course fits into your Tech career Future professors (waves and vibrations, intermediate mechanics, E&M, astrophysics) can assign you numerical problems, confident that you have the skills to tackle them.
R.Sonnenfeld The default MATLAB Desktop. Figure 1.1–
R.Sonnenfeld
ans =
5*ans ans = 4 r=8/ r =
r r =
s=20*r s = 16
R.Sonnenfeld Scalar Arithmetic Operations Table 1.1– Symbol Operation MATLAB form ^ exponentiation: a b a^b
R.Sonnenfeld Examples of Precedence
8 + 3* ans = 23 8 + (35) ans = 23 (8 + 3) ans = 55 4^2 12 8/4* ans = 0 4^2 12 8/(4*2) ans = 3
R.Sonnenfeld The Assignment Operator The Assignment Operator == (^) TypingTyping x =x = 33 assigns the value 3 to the variableassigns the value 3 to the variable x.x. We can then typeWe can then type x =x = x + 2.x + 2. This assigns the valueThis assigns the value 3 + 2 = 5 to 3 + 2 = 5 to x.x. But in algebra this implies that 0 = 2.But in algebra this implies that 0 = 2. In algebra we can write x + 2 = 20, but in MATLAB weIn algebra we can write x + 2 = 20, but in MATLAB we cannot. cannot. (^) In MATLAB the left side of the = operator must be aIn MATLAB the left side of the = operator must be a single variable. single variable. The right side must be aThe right side must be a computablecomputable value.value.
R.Sonnenfeld Special Variables and Constants Table 1.1– Command Description ans Temporary variable containing the most recent answer. eps Specifies the accuracy of floating point precision. i,j The imaginary unit √−1. Inf Infinity. NaN Indicates an undefined numerical result.
R.Sonnenfeld Numeric Display Formats Table 1.1– Command Description and Example format short Four decimal digits (the default); 13.6745. format long16 digits; 17.27484029463547. format short e Five digits (four decimals) plus exponent; 6.3792e+03. format long e 16 digits (15 decimals) plus exponent; 6.379243784781294e–04.