Engr/Math/Physics 25 Chp11: MuPAD Misc Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege.edu Engineering/Math/Physics 25: Computational Methods 1 Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx Using Greek Letters Can only do ONE letter at time Not ALL std Ltrs convert to Greek • Also Use Ctrl+G Engineering/Math/Physics 25: Computational Methods 2 Some Letters do NOT have conversions Spaces do NOT Convert • Select ONLY letters; NOT letters and a space Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx TypeSetting Symbols Engineering/Math/Physics 25: Computational Methods 3 Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx Greek from Command Bar Make Expression h A cost Use Assignment Operator → := Next Pick-off the Greek from the COMMAND BAR Click the Down Arrow Now type A*cos( *t+ ) Engineering/Math/Physics 25: Computational Methods 4 Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx Greek from Command Bar Then pick off omega & phi from the pulldown list with cursor in the right spot in the “h” expression Some Other Expressions with Greek Pulled From the Command Bar Then hit Enter to create symbolic expression Engineering/Math/Physics 25: Computational Methods 5 Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx “HashTag” PlaceHolders PlaceHolder for items from the Command Bar look Something like: #f, or #x • Sort of Like “HashTag” in Twitter Let take an AntiDerviative, and Calculate some Integrals Engineering/Math/Physics 25: Computational Methods 6 1 1 y 2 2 dy 1 1 y 2 2 dy 7 1 1 y 3 Use the Command Bar Integral Pull-Down Pick first one to expose Place Holders for fcn & var Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 2 2 dy 1 1 y “HashTag” PlaceHolders Replace“HashTags” For Variable EndPoint Definite Integral 2 2 dy 1 1 y 7 dy The symbolic Definite Integral The NUMERIC Definite Integral(s) The HastTags Engineering/Math/Physics 25: Computational Methods 2 2 Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 7 1 1 y 3 2 2 dy Assignment vs. Procedure := does NOT Create a function • It assigns a complex expression to an Abbreviation To Create A Function (MuPad “Procedure”) include characters -> Comparing → Engineering/Math/Physics 25: Computational Methods 8 Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx Quick Plot by Command Bar Find Plot Icon The Template The Result after filling in HashTag Then Fill in the HashTag the the desired Function; say y x sin x Engineering/Math/Physics 25: Computational Methods 9 Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx Adjust Plot MuPad picks the InDep Var limits ±5 Write out Function to set other limits Engineering/Math/Physics 25: Computational Methods 10 2X-Clik the Plot to Fine Tune Plot formatting Using the Object Browser Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx Object Brower (2X Clik Plot) Engineering/Math/Physics 25: Computational Methods 11 Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx delete → early & often In MuPAD there is NO WorkSpace Browser to see if a variable has been evaluated and currently contains a value Use “delete(p)”, where “p” is the variable to be cleared in a manner similar to using “clear” in MATLAB When in Doubt, DELETE if ReUsing a variable symbol Engineering/Math/Physics 25: Computational Methods 12 Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx delete → early & often BOOBY PRIZE → A Variable defined in one WorkBook will CARRY OVER into OTHER WorkBooks • The Deleted Assignment in the original WorkBook can be Recovered by using Evaluate When in doubt → DELETE See File: Multiple_Assigns_Deletions_1204 Engineering/Math/Physics 25: Computational Methods 13 Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx TYU 11.2-1 For a A very Good Exercise See file • ENGR25_TYU11_2_1_Expressions_Functi ons_1204.mn Engineering/Math/Physics 25: Computational Methods 14 Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx TYU11.3 Another Good Exercise • ENGR25_TYU11_3_Expressions_Function s_1204.mn Engineering/Math/Physics 25: Computational Methods 15 Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx Inserting Images into MuPAD Unlike the MATLAB Command Window, IMAGES can be imported into Text Regions of a MuPAD WorkBook Copy the Image then See File • Insert-Graphic_1204.mn – Contains some other “tips” on MuPAD as well Engineering/Math/Physics 25: Computational Methods 16 Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx TYU11.5 → Derivatives Take Some Derivatives • ENGR25_TYU11_5_Derivatives_1204.mn Engineering/Math/Physics 25: Computational Methods 17 Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx TYU11.5 → AntiDerivatives Do Some Integration • ENGR25_TYU11_5_Integration_1204.mn Engineering/Math/Physics 25: Computational Methods 18 Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx Power Series General Power Series: n a0 x a1 x a2 x a3 x ak x an x n 0 1 2 3 k n 0 • A form of a GENERALIZED POLYNOMIAL Power Series Convergence Behavior • Exclusively ONE of the following holds True a) Converges ONLY for x = 0 (Trivial Case) b) Converges for ALL x c) Has a Finite “Radius of Convergence”, R Engineering/Math/Physics 25: Computational Methods 19 Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx Functions as Power Series Many Functions can be represented as Infinitely Long PolyNomials Consider this Function and Domain 1 f x for x 1 1 x The Geometric Series form of f(x) n 1 1x 0 1x1 1x 2 1x 3 1x k 1 x n f x 1 x Thus n 0 n 1 f x xn 1 x n 0 Engineering/Math/Physics 25: Computational Methods 20 for x 1 Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx Taylor Series Consider some general Function, f(x), that might be Represented by a Power n 2 3 Series f x a0 a1 x a2 x a3 x an x n n 0 Thus need to find all CoEfficients, an, such that the Power Series Converges to f(x) over some interval. Stated Mathematically Need an so that: n converges n a x n f x for x R n 0 Engineering/Math/Physics 25: Computational Methods 21 Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx Taylor Series If x = 0 and if f(0) is KNOWN then f 0 a0 a1 0 a2 0 2 a3 03 a0 0 a0 f 0 • a0 done, 1→∞ to go…. Next Differentiate Term-by-Term n df x 2 3 dx a1 2a2 x 3a3 x 4a4 x nan x n 1 n 1 Now if the First Derivative (the Slope) is KNOWN when x = 0, then df dx df a1 2a2 0 3a3 0 4a4 0 a1 0 a1 dx 2 x 0 Engineering/Math/Physics 25: Computational Methods 22 3 Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx x 0 Taylor Series Again Differentiate Term-by-Term n d2 f 2 n2 2 a 3 2 a x 4 3 a x n n 1 a x 2 3 4 n 2 dx n2 Now if the 2nd Derivative (the Curvature) is KNOWN when x = 0, then d2 f dx 2 x 0 2 d f 2 2a2 3 2a3 0 4 3a4 0 2a2 0 2a2 2 dx Engineering/Math/Physics 25: Computational Methods 23 Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx x 0 Taylor Series Another Differentiation 3 n d f 2 n 3 3 2 a 4 3 2 a x 5 4 3 a x n n 1 n 2 a x 3 4 4 n 3 dx n 3 d3 f dx 3 Again if the 3rd Derivative is KNOWN at x=0 x 0 3 d f 2 3 2a3 4 3 2a4 0 5 4 3a4 0 6a3 0 6a3 3 dx Recognizing the Pattern: d n f n!an n dx Engineering/Math/Physics 25: Computational Methods 24 an x 0 d n f dx n n! Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx x 0 x 0 Taylor Series Thus to Construct a Taylor (Power) Series about an interval “Centered” at x = 0 for the Function f(x) • Find the Values of ALL the Derivatives of f(x) when x = 0 n • Calculate the Values of the Taylor Series CoEfficients by an • Finally Construct the Power Series from the CoEfficients Engineering/Math/Physics 25: Computational Methods 25 d f dx n n! n f x an x n n 0 Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx x 0 Example Taylor Series for ln(e+x) Calculate the Derivatives df dx d 1 lne x dx e x d 2 f dx 2 d 1 1 dx e x e x 2 d 3 f dx 3 d 1 2 2 dx e x e x 3 Find the Values of the Derivatives at 0 df dxx 0 1 1 e0 e d 2 Engineering/Math/Physics 25: Computational Methods 26 f dx 2 x 0 1 1 2 2 e 0 e d 3 f dx 3 x 0 2 2 3 3 e 0 e Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx Example Taylor Series for ln(e+x) Generally d n f dx n x 0 1 nn 1! for n 1 e Then the CoEfficients n 1 an d n f dx n! n x 0 1n1 n 1! n e n! 1 n 1 ne n for n 1 The 1st four CoEfficients ln(e + 0) 1 (e + 0) 1 a0 = =1 a1 = = 0! 1! e -1 (e + 0)2 1 2 (e + 0)3 1 a2 = = - 2 a3 = = 3 2! 2e 3! 3e Engineering/Math/Physics 25: Computational Methods 27 Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx Example Taylor Series for ln(e+x) Then the Taylor Series ln e x a0 x 0 an x n n 1 n 1 n 1 0 a0 x x n n 1 n e (1) n 1 x n ln(e x) 1 n ne n 1 Engineering/Math/Physics 25: Computational Methods 28 Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx Taylor Series at x ≠ 0 The Taylor Series “Expansion” can Occur at “Center” Values other than 0 Consider a function n n f x a x b stated in a series n n 0 centered at b, that is: Now the Radius of Convergence for the function is the SAME as the Zero Case: x b R R x b R R b x bb R b R b x R b Engineering/Math/Physics 25: Computational Methods 29 Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx Taylor Series at x ≠ 0 To find the CoEfficients n d f need (x−b) = 0 which dx n x b f n b requires x = b, Then the an n! n! CoEfficient Expression The expansion about non-zero centers is useful for functions (or the derivatives) that are NOT DEFINED when x=0 • For Example ln(x) can NOT be expanded about zero, but it can be about, say, 2 Engineering/Math/Physics 25: Computational Methods 30 Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx Example Expand x½ about 4 Expand about b = 4: f x x The 1st four Taylor CoEfficients 4 a0 = =2 0! 1 -1/2 (4) 1 2 a1 = = 1! 4 1 -3/2 - (4) 1 4 a2 = =2! 64 3 -5/2 (4) 1 8 a3 = =3! 512 Engineering/Math/Physics 25: Computational Methods 31 Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx Example Expand x½ about 4 SOLUTION: Use the CoEfficients to Construct the Taylor Series centered at b = 4 x an ( x b) n n 0 1 1 1 5 2 3 = 2 + (x - 4) - (x - 4) + (x - 4) (x - 4)4 +... 4 64 512 16384 Engineering/Math/Physics 25: Computational Methods 32 Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx Example Expand x½ about 4 Use the Taylor Series centered at b = 4 to Find the Square Root of 3 4 n 0 n 0 3 an (3 b) n an (3 b) n 1 1 1 5 2 3 2 (3 4) (3 4) (3 4) (3 4) 4 4 64 512 16384 1 1 1 5 2 3 2 (1) (1) (1) (1) 4 4 64 512 16384 2 0.25 0.0156 0.0020 0.0003 2 0.2679 1.7321 By MATLAB 1.7320508 Engineering/Math/Physics 25: Computational Methods 33 Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx Expand About b=1, ln(x)/1 Da1 := diff(ln(x)/x, x) df dx 1 0 2 1 x 1 Db2 := diff(Da1, x) d2 f dx 2 0 x 1 3 15 ReCall that ln(1) = 0 Dc3 := diff(Db2, x) d3 f dx 3 x 1 11 0 4 1 Dd4 := diff(Dc3, x) d4 f dx 4 Engineering/Math/Physics 25: Computational Methods 34 0 x 1 50 15 Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx Expand About b=1, ln(x)/1 ln(x)/x, x f0 := taylor(ln(x)/x, x = 1, 0) f1 := taylor(ln(x)/x, x = 1, 1) f2 := taylor(ln(x)/x, x = 1, 2) Engineering/Math/Physics 25: Computational Methods 35 Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx Expand About b=1, ln(x)/1 f3 := taylor(ln(x)/x, x = 1, 3) f4 := taylor(ln(x)/x, x = 1, 4) d6 := diff(ln(x)/x, x $ 5) d5 f dx 5 x 1 274 0 6 1 0 x 1 3 1 x 1 11 1 x 1 50 1 x 1 274 1 x 1 lnx 0! 1! 2! 3! 4! 5! 1 2 Engineering/Math/Physics 25: Computational Methods 36 3 4 Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 5 Expand About b=1, ln(x)/1 plot(f0, f1, f2, f3, f4, f5, x =0.5..3, GridVisible = TRUE, LineWidth = 0.04*unit::inch, Width = 320*unit::mm, Height = 180*unit::mm, AxesTitleFont = ["sans-serif", 24], TicksLabelFont=["sans-serif", 16]) Engineering/Math/Physics 25: Computational Methods 37 Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx Engineering/Math/Physics 25: Computational Methods 38 Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx Engineering/Math/Physics 25: Computational Methods 39 Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx Engineering/Math/Physics 25: Computational Methods 40 Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx TYU 11.5 → Sums & Series Exercise Taylor’s Series & Sums • ENGR25_TYU11_5_6789_Taylor_Sums_L imits_1204.mn Engineering/Math/Physics 25: Computational Methods 41 Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx TYU11.6 → ODEs Do an ODE Solution • file = ENGR25_TYU11_6_ODE_1204.mn – By: File → Export → PDF Engineering/Math/Physics 25: Computational Methods 42 Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx All Done for Today It’s All GREEK to me… Engineering/Math/Physics 25: Computational Methods 43 Bruce Mayer, PE BMayer@ChabotCollege.edu ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx