From 97d960b5c310c54f9f41575dfa82551c8cb97e2a Mon Sep 17 00:00:00 2001 From: Luc Street Date: Sun, 7 Oct 2018 18:20:19 -0700 Subject: [PATCH 1/2] Using/plotting series in Mathematica --- sheets/_mathematica/series | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 sheets/_mathematica/series diff --git a/sheets/_mathematica/series b/sheets/_mathematica/series new file mode 100644 index 0000000..cfce940 --- /dev/null +++ b/sheets/_mathematica/series @@ -0,0 +1,21 @@ +Generate a Taylor series expansion of cos(x) using x, expanding about x = 0 and +continuing until a term with x^6. Taylor series about x = 0 are called Maclaurin +series. + +Series[Cos[x], {x, 0, 6}] +1 - x^2/2 + x^4/24 - x^6/720 + O[x]^7 + +The 'O[x]^7' just represents the rest of the series, which we don't care about. +If you don't want it displayed, just wrap the call to Series inside a call to +Normal: Normal[Series[...]]. This is useful for plotting series. + +Here's the same function, but expanded about a different point, x = 3pi/2: + +Series[Cos[x], {x, 3 Pi/2, 6}] +(x-3pi/2) - 1/6*(x-3pi/2)^3 + 1/120*(x-3pi/2)^5 + O[x-3pi/2]^7 + +When plotting series, remember to wrap the function in both a call to Normal AND +a call to Evaluate: this strips the extra term mentioned previously and tells +Mathematica to actually evaluate the function rather than hold it as an expression. + +Plot[Evaluate[Normal[Series[Cos[x], {x, 0, 6}]]], {x, 0, 1}] From e951a12fd328b79be06ea870a96813739d43ad57 Mon Sep 17 00:00:00 2001 From: Igor Chubin Date: Mon, 8 Oct 2018 12:07:23 +0200 Subject: [PATCH 2/2] Update series --- sheets/_mathematica/series | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/sheets/_mathematica/series b/sheets/_mathematica/series index cfce940..b93dc3e 100644 --- a/sheets/_mathematica/series +++ b/sheets/_mathematica/series @@ -1,21 +1,27 @@ -Generate a Taylor series expansion of cos(x) using x, expanding about x = 0 and -continuing until a term with x^6. Taylor series about x = 0 are called Maclaurin -series. +(* + * Generate a Taylor series expansion of cos(x) using x, expanding about x = 0 and + * continuing until a term with x^6. Taylor series about x = 0 are called Maclaurin + * series. + *) Series[Cos[x], {x, 0, 6}] 1 - x^2/2 + x^4/24 - x^6/720 + O[x]^7 -The 'O[x]^7' just represents the rest of the series, which we don't care about. -If you don't want it displayed, just wrap the call to Series inside a call to -Normal: Normal[Series[...]]. This is useful for plotting series. - -Here's the same function, but expanded about a different point, x = 3pi/2: - +(* + * The 'O[x]^7' just represents the rest of the series, which we don't care about. + * If you don't want it displayed, just wrap the call to Series inside a call to + * Normal: Normal[Series[...]]. This is useful for plotting series. + * + * Here's the same function, but expanded about a different point, x = 3pi/2: + *) + Series[Cos[x], {x, 3 Pi/2, 6}] (x-3pi/2) - 1/6*(x-3pi/2)^3 + 1/120*(x-3pi/2)^5 + O[x-3pi/2]^7 -When plotting series, remember to wrap the function in both a call to Normal AND -a call to Evaluate: this strips the extra term mentioned previously and tells -Mathematica to actually evaluate the function rather than hold it as an expression. +(* + * When plotting series, remember to wrap the function in both a call to Normal AND + * a call to Evaluate: this strips the extra term mentioned previously and tells + * Mathematica to actually evaluate the function rather than hold it as an expression. + *) Plot[Evaluate[Normal[Series[Cos[x], {x, 0, 6}]]], {x, 0, 1}]