Difference between revisions of "Inverse Composition Rules"

From JSXGraph Wiki
Jump to navigationJump to search
Line 13: Line 13:
 
  <tr>
 
  <tr>
 
   <td>&nbsp;</td>
 
   <td>&nbsp;</td>
   <td><input type="radio" name="f" value="sin" checked onChange="change(f,this)"></td>
+
   <td><input type="radio" name="f" value="sin" checked onChange="change(this)"></td>
   <td><input type="radio" name="f" value="cos"        onChange="change(f,this)"></td>
+
   <td><input type="radio" name="f" value="cos"        onChange="change(this)"></td>
   <td><input type="radio" name="f" value="tan"        onChange="change(f,this)"></td>
+
   <td><input type="radio" name="f" value="tan"        onChange="change(this)"></td>
   <td><input type="radio" name="f" value="square"      onChange="change(f,this)"></td>
+
   <td><input type="radio" name="f" value="square"      onChange="change(this)"></td>
   <td><input type="radio" name="f" value="sinh"        onChange="change(f,this)"></td>
+
   <td><input type="radio" name="f" value="sinh"        onChange="change(this)"></td>
   <td><input type="radio" name="f" value="exp"        onChange="change(f,this)"></td>
+
   <td><input type="radio" name="f" value="exp"        onChange="change(this)"></td>
 
  </tr>
 
  </tr>
 
  <tr>
 
  <tr>
Line 31: Line 31:
 
  <tr>
 
  <tr>
 
   <td>&nbsp;</td>
 
   <td>&nbsp;</td>
   <td><input type="radio" name="g" value="asin" checked onChange="change(g,this)"></td>
+
   <td><input type="radio" name="g" value="asin" checked onChange="change(this)"></td>
   <td><input type="radio" name="g" value="acos"        onChange="change(g,this)"></td>
+
   <td><input type="radio" name="g" value="acos"        onChange="change(this)"></td>
   <td><input type="radio" name="g" value="atan"        onChange="change(g,this)"></td>
+
   <td><input type="radio" name="g" value="atan"        onChange="change(this)"></td>
   <td><input type="radio" name="g" value="sqrt"        onChange="change(g,this)"></td>
+
   <td><input type="radio" name="g" value="sqrt"        onChange="change(this)"></td>
   <td><input type="radio" name="g" value="asinh"        onChange="change(g,this)"></td>
+
   <td><input type="radio" name="g" value="asinh"        onChange="change(this)"></td>
   <td><input type="radio" name="g" value="log"          onChange="change(g,this)"></td>
+
   <td><input type="radio" name="g" value="log"          onChange="change(this)"></td>
 
  </tr>
 
  </tr>
 
</table>
 
</table>
Line 45: Line 45:
 
var f, g;
 
var f, g;
  
var change = function(func,obj) {
+
var change = function(obj) {
 
  var t = obj.value;  
 
  var t = obj.value;  
  if (t=='sin') { func = function(x) { return Math.sin(x); }  
+
  if (t=='sin')           { f = function(x) { return Math.sin(x); }  
  } else if (t=='cos') { func = function(x) { return Math.cos(x); }
+
  } else if (t=='cos')   { f = function(x) { return Math.cos(x); }
  } else if (t=='tan') { func = function(x) { return Math.tan(x); }
+
  } else if (t=='tan')   { f = function(x) { return Math.tan(x); }
  } else if (t=='square') { func = function(x) { return x*x; }
+
  } else if (t=='square') { f = function(x) { return x*x; }
  } else if (t=='sinh') { func = function(x) { return brd.sinh(x); }
+
  } else if (t=='sinh')   { f = function(x) { return brd.sinh(x); }
  } else if (t=='exp') { func = function(x) { return Math.exp(x); }
+
  } else if (t=='exp')   { f = function(x) { return Math.exp(x); }
  
  } else if (t=='asin') { func = function(x) { return Math.asin(x); }
+
  } else if (t=='asin')   { g = function(x) { return Math.asin(x); }
  } else if (t=='acos') { func = function(x) { return Math.acos(x); }
+
  } else if (t=='acos')   { g = function(x) { return Math.acos(x); }
  } else if (t=='atan') { func = function(x) { return Math.atan(x); }
+
  } else if (t=='atan')   { g = function(x) { return Math.atan(x); }
  } else if (t=='sqrt') { func = function(x) { return Math.sqrt(x); }
+
  } else if (t=='sqrt')   { g = function(x) { return Math.sqrt(x); }
  } else if (t=='asinh') { func = function(x) { return Math.log(x+Math.sqrt(1+x*x)); }
+
  } else if (t=='asinh') { g = function(x) { return Math.log(x+Math.sqrt(1+x*x)); }
  } else if (t=='log') { func = function(x) { return Math.log(x); }
+
  } else if (t=='log')   { g = function(x) { return Math.log(x); }
 
  }
 
  }
 
  alert(f.toString());
 
  alert(f.toString());

Revision as of 15:38, 19 June 2009

f(x) sin(x) cos(x) tan(x) x2 sinh(x) exp(x)
 
g(x) arcsin(x) arccos(x) arctan(x) √(x) arcsinh(x) log(x)
 

The underlying JavaScript code