Created
February 13, 2012 23:01
-
-
Save kenwebb/1821297 to your computer and use it in GitHub Desktop.
Determining the equation of a trigonometric function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!--Xholon Workbook http://www.primordion.com/Xholon/wb/ (C) Ken Webb Mon Feb 13 2012 18:01:33 GMT-0500 (EST)--> | |
<XholonWorkbook> | |
<Notes><![CDATA[ | |
Khan Academy | |
------------ | |
Title: Determining the equation of a trigonometric function | |
Description: Determining the amplitude and period of sine and cosine functions. | |
Url: http://www.khanacademy.org/video/determining-the-equation-of-a-trigonometric-function?playlist=Trigonometry | |
InternalName: determining-the-equation-of-a-trigonometric-function | |
YoutubeId: yvW5l9W1hgE | |
Keywords: Period, amplitude, sine, cosine, sin, cos, trigonometry, CC_39336_F-IF_7_e | |
Problem 1 0:00 | |
--------- | |
start with a graph of a sine or cosine curve | |
sin(0) = 0 and cos(0) = 1 | |
there must be a coefficient, which is the amplitude A of the curve | |
f(x) = (3/2) * cos(2*PI / pX), where pX is the period of X, and amplitude is 3/2 = 1.5 | |
how many radians until the graph starts repeating? period = 4 * PI | |
f(x) = 3/2 * cos((2*PI / 4*PI) * x) = 1.5 * (cos(0.5 * x)) | |
Problem 2 5:15 | |
--------- | |
A = 1 | |
this is a sine function | |
cycles 4 times in 2PI radians, so the period is 4; the coefficient of the x term | |
f(x) = 1 * sin(4x) | |
Problem 3 7:15 | |
--------- | |
A = 0.5 | |
cycles 0.5 times in 2PI radians | |
period = 4PI | |
f(0) = 0 | |
f(x) = 0.5 * sin(0.5x) | |
]]></Notes> | |
<script implName="lang:python:inline:"><![CDATA[ | |
print "TODO" | |
]]></script> | |
<script implName="lang:javascript:inline:"><![CDATA[ | |
// Problem 1 - calculate f(x) for one value of x | |
// I've run it for these values of x to confirm it agrees with Sal's video | |
// 0 PI 2PI 3PI 4PI -PI -2PI -3PI -4PI | |
var x = 0; | |
var a = 1.5; | |
var p = 4 * Math.PI; | |
var twoPI = 2 * Math.PI; | |
var f = a * Math.cos((twoPI / p) * x); | |
print("f(" + x + ") = " + f + "\n"); | |
// Problem 2 | |
x = 0; | |
print(1 * Math.sin(4 * x) + "\n"); | |
// Problem 3 | |
x = 0; | |
print(0.5 * Math.sin(0.5 * x) + "\n"); | |
]]></script> | |
<_-.XholonClass> | |
<!-- domain objects --> | |
<TrigSystem/> | |
<Problem/> | |
<X/> | |
<Amplitude/> | |
<Period/> <!-- 4PI --> | |
<Y/> | |
<!-- quantities --> | |
<!-- I'll assume all the quantities are dimensionless scalars --> | |
</_-.XholonClass> | |
<xholonClassDetails> | |
<Problem> | |
<port name="x" connector="#xpointer(X)"/> | |
<port name="a" connector="#xpointer(Amplitude)"/> | |
<port name="p" connector="#xpointer(Period)"/> | |
<port name="twoPI" connector="#xpointer(../Constants/TwoPi)"/> | |
<port name="y" connector="#xpointer(Y)"/> | |
</Problem> | |
<!-- X and Y are passive objects that will be graphed --> | |
<X xhType="XhtypePurePassiveObject"/> | |
<Y xhType="XhtypePurePassiveObject"/> | |
</xholonClassDetails> | |
<TrigSystem> | |
<Problem roleName="one"> | |
<X>0.0</X> | |
<Amplitude>1.5</Amplitude> | |
<Period/> | |
<Y>0.0</Y> | |
<OneProblembehavior implName="org.primordion.script.Behavior_javascript"><![CDATA[ | |
var behaviorObject = new Object(); | |
behaviorObject.postConfigure = function() { | |
var app = applicationKey; | |
app.setUseDataPlotter('JFreeChart'); | |
app.setDataPlotterParams('Graph of trig function f(x) = 1.5 * (cos(0.5 * x)),Time (timesteps),X Y,./statistics/,stats,1,WRITE_AS_LONG'); | |
app.createChart(contextNodeKey.getParentNode()); | |
p.setVal(4 * Math.PI); | |
} | |
behaviorObject.act = function() { | |
x.setVal(x.val + 0.1); // try the next value of x | |
var f = a.val * Math.cos((twoPI.val / p.val) * x.val); | |
y.setVal(f); | |
}]]></OneProblembehavior> | |
</Problem> | |
<Constants> | |
<!-- these are available thru JScience --> | |
<Pi/> | |
<HalfPi/> | |
<TwoPi/> | |
<FourPi/> | |
</Constants> | |
</TrigSystem> | |
<OneProblembehavior implName="org.primordion.script.Behavior_javascript"><![CDATA[]]></OneProblembehavior> | |
<OneProblembehavior implName="lang:javascript:inline:"><![CDATA[ | |
// As an optional test, paste in as a last child of Problem one. | |
p.setVal(4 * Math.PI); | |
var f = a.val * Math.cos((twoPI.val / p.val) * x.val); | |
y.setVal(f); | |
print("f(" + x.val + ") = " + y.val + "\n"); | |
]]></OneProblembehavior> | |
<Blockbehavior implName="lang:bsh:inline:"><![CDATA[]]></Blockbehavior> | |
<Blockbehavior implName="lang:jruby:inline:"><![CDATA[]]></Blockbehavior> | |
<Blockbehavior implName="lang:groovy:inline:"><![CDATA[]]></Blockbehavior> | |
<SvgClient><Attribute_String roleName="svgUri"><![CDATA[data:image/svg+xml, | |
]]></Attribute_String><Attribute_String roleName="setup">${MODELNAME_DEFAULT},${SVGURI_DEFAULT}</Attribute_String></SvgClient> | |
</XholonWorkbook> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment