{"id":1158,"date":"2014-10-08T09:57:38","date_gmt":"2014-10-08T13:57:38","guid":{"rendered":"https:\/\/blogs.mathworks.com\/steve\/?p=1158"},"modified":"2019-11-01T11:22:17","modified_gmt":"2019-11-01T15:22:17","slug":"eulers-formula-and-trig-identities","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/steve\/2014\/10\/08\/eulers-formula-and-trig-identities\/","title":{"rendered":"Euler&#8217;s formula and trig identities"},"content":{"rendered":"\r\n<div class=\"content\"><p>I'm terrible at rote memorization.<\/p><p>I thought about that recently when I happened to see a plot (I think it was in a documentation example) that compared $sin(\\theta)$, $cos(\\theta)$, and $sin(\\theta) cos(\\theta)$.<\/p><pre class=\"codeinput\">theta = linspace(0,6*pi,500);\r\nplot(theta,sin(theta))\r\nhold <span class=\"string\">on<\/span>\r\nplot(theta,cos(theta))\r\nplot(theta,sin(theta) .* cos(theta))\r\nhold <span class=\"string\">off<\/span>\r\nlegend({<span class=\"string\">'sin(\\theta)'<\/span>,<span class=\"string\">'cos(\\theta)'<\/span>,<span class=\"string\">'sin(\\theta) cos(\\theta)'<\/span>})\r\n<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/2014\/euler_formula_01.png\" alt=\"\"> <p>Hmm, I thought. I guess $sin(\\theta) cos(\\theta)$ is just a sinusoid with twice the frequency and half the amplitude.<\/p><p>How is that related to memorization, you might ask? Well, I always had a very hard time remembering trig identities in high school and college. But, as an electrical engineering student, I had the following formula engraved on my brain cells:<\/p><p>$$e^{j\\theta} = cos(\\theta) + j sin(\\theta)$$<\/p><p>(Note that I am following the proud electrical engineering tradition of using <i>j<\/i> instead of <i>i<\/i> as the imaginary unit. Because <i>i<\/i> obviously stands for current.)<\/p><p>This is called Euler's formula, and it's used all over the place in electrical engineering. I did not know at the time that Richard Feynman called it \"the most remarkable formula in mathematics.\"<\/p><p>Here are a couple of closely related formulas:<\/p><p>$$cos(\\theta) = \\frac{1}{2} (e^{j\\theta} + e^{-j\\theta})$$<\/p><p>$$sin(\\theta) = \\frac{1}{2j} (e^{j\\theta} - e^{-j\\theta})$$<\/p><p>At some point during my undergraduate days, it dawned on me that I could derive many of the common trig identities directly from these formulas. Here's how it goes for $sin(\\theta) cos(\\theta)$:<\/p><p>$$\r\nsin(\\theta) cos(\\theta) = \\frac{1}{2j} (e^{j\\theta} - e^{-j\\theta})\r\n\\frac{1}{2} (e^{j\\theta} + e^{-j\\theta})\r\n$$<\/p><p>$$\r\nsin(\\theta) cos(\\theta) = \\frac{1}{4j} (e^{j2\\theta} - e^{-j2\\theta} + 1 - 1)\r\n$$<\/p><p>$$\r\nsin(\\theta) cos(\\theta) = \\frac{1}{2} \\frac{1}{2j} (e^{j2\\theta} -\r\ne^{-j2\\theta})\r\n$$<\/p><p>$$\r\nsin(\\theta) cos(\\theta) = \\frac{1}{2} sin(2\\theta)\r\n$$<\/p><p>Presto! Like magic.<\/p><p>I used to think that I must be kind of weird to prefer this manipulation of Euler's formula to simply memorizing the trig identities. But while writing this blog today, I noticed that the <a href=\"http:\/\/en.wikipedia.org\/wiki\/Euler's_formula\">Wikipedia article on Euler's formula<\/a> describes this concept exactly. \"Complex exponentials can simplify trigonometry, because they are easier to manipulate than their sinusoidal components.\"<\/p><p>OK!<\/p><p>PS. In my plot creation code above, I exploited a subtle improvement in MATLAB R2014b graphics that customers have been requesting for many years. Can you spot it?<\/p><script language=\"JavaScript\"> <!-- \r\n    function grabCode_151e377b3685425c9ed7b006beb8e8c1() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='151e377b3685425c9ed7b006beb8e8c1 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 151e377b3685425c9ed7b006beb8e8c1';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        copyright = 'Copyright 2014 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add copyright line at the bottom if specified.\r\n        if (copyright.length > 0) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\\n');\r\n\r\n        d.title = title + ' (MATLAB code)';\r\n        d.close();\r\n    }   \r\n     --> <\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_151e377b3685425c9ed7b006beb8e8c1()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n      the MATLAB code <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; R2014b<br><\/p><\/div><!--\r\n151e377b3685425c9ed7b006beb8e8c1 ##### SOURCE BEGIN #####\r\n%%\r\n% I'm terrible at rote memorization.\r\n%\r\n% I thought about that recently when I happened to see a plot (I think it was in\r\n% a documentation example) that compared $sin(\\theta)$, $cos(\\theta)$, and\r\n% $sin(\\theta) cos(\\theta)$.\r\n\r\ntheta = linspace(0,6*pi,500);\r\nplot(theta,sin(theta))\r\nhold on\r\nplot(theta,cos(theta))\r\nplot(theta,sin(theta) .* cos(theta))\r\nhold off\r\nlegend({'sin(\\theta)','cos(\\theta)','sin(\\theta) cos(\\theta)'})\r\n\r\n%%\r\n% Hmm, I thought. I guess $sin(\\theta) cos(\\theta)$ is just a sinusoid with\r\n% twice the frequency and half the amplitude.\r\n%\r\n% How is that related to memorization, you might ask? Well, I always had a very\r\n% hard time remembering trig identities in high school and college. But, as an\r\n% electrical engineering student, I had the following formula engraved on my\r\n% brain cells:\r\n%\r\n% $$e^{j\\theta} = cos(\\theta) + j sin(\\theta)$$\r\n%\r\n% (Note that I am following the proud electrical engineering tradition of using\r\n% _j_ instead of _i_ as the imaginary unit. Because _i_ obviously stands for\r\n% current.)\r\n%\r\n% This is called Euler's formula, and it's used all over the place in electrical\r\n% engineering. I did not know at the time that Richard Feynman called it \"the\r\n% most remarkable formula in mathematics.\"\r\n%\r\n% Here are a couple of closely related formulas:\r\n%\r\n% $$cos(\\theta) = \\frac{1}{2} (e^{j\\theta} + e^{-j\\theta})$$\r\n%\r\n% $$sin(\\theta) = \\frac{1}{2j} (e^{j\\theta} - e^{-j\\theta})$$\r\n%\r\n% At some point during my undergraduate days, it dawned on me that I could\r\n% derive many of the common trig identities directly from these formulas. Here's\r\n% how it goes for $sin(\\theta) cos(\\theta)$:\r\n%\r\n% $$\r\n% sin(\\theta) cos(\\theta) = \\frac{1}{2j} (e^{j\\theta} - e^{-j\\theta})\r\n% \\frac{1}{2} (e^{j\\theta} + e^{-j\\theta})\r\n% $$\r\n%\r\n% $$\r\n% sin(\\theta) cos(\\theta) = \\frac{1}{4j} (e^{j2\\theta} - e^{-j2\\theta} + 1 - 1)\r\n% $$\r\n%\r\n% $$\r\n% sin(\\theta) cos(\\theta) = \\frac{1}{2} \\frac{1}{2j} (e^{j2\\theta} -\r\n% e^{-j2\\theta})\r\n% $$\r\n%\r\n% $$\r\n% sin(\\theta) cos(\\theta) = \\frac{1}{2} sin(2\\theta)\r\n% $$\r\n%\r\n% Presto! Like magic.\r\n%\r\n% I used to think that I must be kind of weird to prefer this \r\n% manipulation of Euler's formula to simply memorizing the trig identities. But\r\n% while writing this blog today, I noticed that the \r\n% <http:\/\/en.wikipedia.org\/wiki\/Euler's_formula Wikipedia article on Euler's\r\n% formula> describes this concept exactly. \"Complex exponentials can simplify\r\n% trigonometry, because they are easier to manipulate than their sinusoidal\r\n% components.\"\r\n%\r\n% OK!\r\n%\r\n% PS. In my plot creation code above, I exploited a subtle improvement in MATLAB\r\n% R2014b graphics that customers have been requesting for many years. Can you\r\n% spot it?\r\n##### SOURCE END ##### 151e377b3685425c9ed7b006beb8e8c1\r\n-->","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/2014\/euler_formula_01.png\" onError=\"this.style.display ='none';\" \/><\/div><p>\r\nI'm terrible at rote memorization.I thought about that recently when I happened to see a plot (I think it was in a documentation example) that compared $sin(\\theta)$, $cos(\\theta)$, and... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/steve\/2014\/10\/08\/eulers-formula-and-trig-identities\/\">read more >><\/a><\/p>","protected":false},"author":42,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[74,90,92,32,68,34],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts\/1158"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/users\/42"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/comments?post=1158"}],"version-history":[{"count":5,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts\/1158\/revisions"}],"predecessor-version":[{"id":1180,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts\/1158\/revisions\/1180"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/media?parent=1158"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/categories?post=1158"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/tags?post=1158"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}