うしブログ

うしブログ

趣味で運営する、GeoGebraの専門ブログ。

(作業メモ)StartPoint要検証(2行の場合;テキスト変更時未定義問題)

従属オブジェクトの定義をネストする

課題

たとえば、以下のオブジェクトを、上から順に作成する。

C = (1,1)

r = 2

s = r+1

d = Circle[C,r]

e = Circle[C,s]

output = (Area[e] - Area[d]) / (s^2-r^2)

ここで、JavaScript関数

nest( 'output', ['C','r'] );

を実行することで、outputを、Cとrのみを用いて定義した文字列

 '( Area[Circle[C,r+1]] - Area[Circle[C,r]] ) / ( (r+1)^2-r^2 )'

を取得したい(当該文字列を関数の戻り値としてもよいが、さしあたり、ブラウザのコンソールに出力できれば十分である)。

このように、ある従属オブジェクトの定義を、指定したオブジェクトのみで表した場合の文字列を得られるような、関数nestを作成せよ。

※これができると、オリジナルツール作成が、とても捗る。 

関数作成例

//nest('f', ['a', 'b']):a,b以外の従属オブジェクトを用いないように、fの定義をネストして、コンソールに出力する。(まず使わないと思うが)オブジェクト名にOBJECT+数値+USIDESUを使わないように注意。
function nest(objName, objectToProtectArray){

  //フェイルセーフ
  if(!ggbApplet.exists(objName)){return objName+' is undefined.';}  //objNameが存在しないとき処理終了
  if(ggbApplet.getCommandString(objName, false)==''){return 'it is a freeObject.';}  //ターゲットが自由オブジェクトなら処理終了
  if(!objectToProtectArray){var objectToProtectArray = [];}  //objectToProtectArrayがundefinedのとき[]を代入

  //名前変更前のオブジェクト名リストを取得
  var originalNameArray = ggbApplet.getAllObjectNames();
  //ターゲットのindexを取得
  var indexOfTarget = originalNameArray.indexOf(objName);
//  console.log('indexOfTarget→'); 
//  console.log(indexOfTarget); 

  //保護オブジェクト配列の(originalNameArrayにおける)indexを取得
  var indexArrayOfObjectToProtect = objectToProtectArray.map(function(value){
    return originalNameArray.indexOf(value);
  });
//  console.log('indexArrayOfObjectToProtect→'); 
//  console.log(indexArrayOfObjectToProtect); 

  //名前変更
  for(var k=0; k<originalNameArray.length; k++){
    ggbApplet.renameObject(originalNameArray[k], 'OBJECT'+k+'USIDESU');
  }

  //名前変更後のオブジェクト名リストを取得
  var changedNameArray = ggbApplet.getAllObjectNames();

  //名前変更後のターゲット名を取得
  var changedNameOfTarget = ggbApplet.getObjectName(indexOfTarget);
  //ターゲットの定義を取得
  var definitionOfTarget = ggbApplet.getCommandString(changedNameOfTarget, false);
//  console.log('definitionOfTarget→'); 
//  console.log(definitionOfTarget); 
  //名前変更後の保護オブジェクトの名前リストを取得
  var changedNameArrayOfObjectToProtect = indexArrayOfObjectToProtect.map(function(value){
    return ggbApplet.getObjectName(value);
  });
//  console.log('changedNameArrayOfObjectToProtect→'); 
//  console.log(changedNameArrayOfObjectToProtect); 

  //ネスト処理ループ
  do{
    //親オブジェクトの名前リストを取得
    var nameOfParentObjects = definitionOfTarget.match( /OBJECT\d+USIDESU/g );
    if(!nameOfParentObjects){nameOfParentObjects = [''];}
//    console.log('nameOfParentObjects→'); 
//    console.log(nameOfParentObjects); 
    //親オブジェクトの定義を取得(ただし保護オブジェクトは''扱い)
    var definitionOfParentObjects = nameOfParentObjects.map(function(value){
      if(changedNameArrayOfObjectToProtect.indexOf(value)!=-1){return '';}
      else{return ggbApplet.getCommandString(value, false);}
    });  //自由オブジェクトおよび保護オブジェクトは''をとる
//    console.log('definitionOfParentObjects→'); 
//    console.log(definitionOfParentObjects); 
    //ネスト
    var nestedDefinitionOfTarget = definitionOfTarget;
    for(var k=0; k<nameOfParentObjects.length; k++){
      if(definitionOfParentObjects[k]!=''){
        var re = new RegExp(nameOfParentObjects[k], 'g');
        nestedDefinitionOfTarget = nestedDefinitionOfTarget.replace(re, '('+definitionOfParentObjects[k]+')');
      }
    }
//    console.log('nestedDefinitionOfTarget→');
//    console.log(nestedDefinitionOfTarget);
    definitionOfTarget = nestedDefinitionOfTarget;
  } while (definitionOfParentObjects.join('')!='');

  //ネスト定義文字列の名前を戻す
  for(var k=0; k<originalNameArray.length; k++){
    var usidesuReg = new RegExp(changedNameArray[k], 'g');
    nestedDefinitionOfTarget = nestedDefinitionOfTarget.replace(usidesuReg, originalNameArray[k]);
  }

  //console.log('nestedDefinitionOfTarget→');
  console.log(nestedDefinitionOfTarget);

  //名前を戻す
  for(var k=0; k<originalNameArray.length; k++){
    ggbApplet.renameObject('OBJECT'+k+'USIDESU', originalNameArray[k]);
  }

}

GeoGebraで増減表を作成するオリジナルツール「DerivativeChart」

使用例

ダウンロード

DerivativeChart Tool - GeoGebra

説明

指定した区間における、関数の増減表を返します。同時に、指定した区間における極大点、極小点、変曲点のリストを返します。

ただし、関数は、指定区間において微分可能でなければ、正しい結果を返しません。

構文は、

DerivativeChart[ <xの関数>, <xの開始値>, <xの終了値> ]

です。

このツールは、GeoGebra バージョン 6.0.518.0-w (20 December 2018) にて動作確認しました。本ツールはβ版です。

バグ情報(随時修正予定)

・引数に1次関数を指定すると、f''(x)の判定や、増減の矢印の表示に問題あり。すなわち、区間内で、f''(x)が一定値0をとる場合(増減の矢印がまっすぐな場合)に未対応。

 

(参考)

DerivativeChart[ f, min, max ]の戻り値は、以下のように定義されています。

極大点・極小点

Zip[( x(s), f( x(s) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]]

変曲点

Zip[( x(s), f( x(s) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]

増減表

TableText[{Append["x", Sort[Join[{Zip["" + (t), t, Zip[x(s), s, Unique[Sort[Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}], Zip[x(s), s, Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}]]]]]], Zip["•••", s, Sequence[(Element[Zip[x(s), s, Unique[Sort[Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}], Zip[x(s), s, Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}]]]]], t] + Element[Zip[x(s), s, Unique[Sort[Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}], Zip[x(s), s, Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}]]]]], t + 1]) / 2, t, 1, Length[Zip[x(s), s, Unique[Sort[Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}], Zip[x(s), s, Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}]]]]]] - 1]]}], Join[{Zip[x(s), s, Unique[Sort[Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}], Zip[x(s), s, Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}]]]]], Sequence[(Element[Zip[x(s), s, Unique[Sort[Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}], Zip[x(s), s, Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}]]]]], t] + Element[Zip[x(s), s, Unique[Sort[Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}], Zip[x(s), s, Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}]]]]], t + 1]) / 2, t, 1, Length[Zip[x(s), s, Unique[Sort[Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}], Zip[x(s), s, Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}]]]]]] - 1]}]]], Append["f'(x)", Sort[Join[{Zip[If[y(s) > 0, "+", y(s) < 0, "-", y(s) ≟ 0, "0"], s, Unique[Sort[Flatten[{(x( ( min, f(min ) ) ), f'(x( ( min, f(min ) ) ) ) ), (x( ( max, f(max ) ) ), f'(x( ( max, f(max ) ) ) ) ), Zip[(x(t), 0), t, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(t), f'(x(t ) ) ), t, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}], Zip[x(s), s, Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}]]]]], Zip[If[f'(s) > 0, "+", "-"], s, Sequence[(Element[Zip[x(s), s, Unique[Sort[Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}], Zip[x(s), s, Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}]]]]], t] + Element[Zip[x(s), s, Unique[Sort[Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}], Zip[x(s), s, Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}]]]]], t + 1]) / 2, t, 1, Length[Zip[x(s), s, Unique[Sort[Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}], Zip[x(s), s, Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}]]]]]] - 1]]}], Join[{Zip[x(s), s, Unique[Sort[Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}], Zip[x(s), s, Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}]]]]], Sequence[(Element[Zip[x(s), s, Unique[Sort[Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}], Zip[x(s), s, Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}]]]]], t] + Element[Zip[x(s), s, Unique[Sort[Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}], Zip[x(s), s, Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}]]]]], t + 1]) / 2, t, 1, Length[Zip[x(s), s, Unique[Sort[Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}], Zip[x(s), s, Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}]]]]]] - 1]}]]], Append["f''(x)", Sort[Join[{Zip[If[y(s) > 0, "+", y(s) < 0, "-", y(s) ≟ 0, "0"], s, Unique[Sort[Flatten[{(x( ( min, f(min ) ) ), f''(x( ( min, f(min ) ) ) ) ), (x( ( max, f(max ) ) ), f''(x( ( max, f(max ) ) ) ) ), Zip[(x(t), f''(x(t ) ) ), t, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(t), 0), t, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}], Zip[x(s), s, Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}]]]]], Zip[If[f''(s) > 0, "+", "-"], s, Sequence[(Element[Zip[x(s), s, Unique[Sort[Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}], Zip[x(s), s, Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}]]]]], t] + Element[Zip[x(s), s, Unique[Sort[Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}], Zip[x(s), s, Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}]]]]], t + 1]) / 2, t, 1, Length[Zip[x(s), s, Unique[Sort[Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}], Zip[x(s), s, Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}]]]]]] - 1]]}], Join[{Zip[x(s), s, Unique[Sort[Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}], Zip[x(s), s, Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}]]]]], Sequence[(Element[Zip[x(s), s, Unique[Sort[Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}], Zip[x(s), s, Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}]]]]], t] + Element[Zip[x(s), s, Unique[Sort[Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}], Zip[x(s), s, Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}]]]]], t + 1]) / 2, t, 1, Length[Zip[x(s), s, Unique[Sort[Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}], Zip[x(s), s, Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}]]]]]] - 1]}]]], Append["f(x)", Sort[Join[{Zip["" + (s), s, Zip[y(s), s, Unique[Sort[Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}], Zip[x(s), s, Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}]]]]]], Zip[If[(f'(s) > 0) ∧ (f''(s) > 0), "⤴", (f'(s) > 0) ∧ (f''(s) < 0), "↱", (f'(s) < 0) ∧ (f''(s) > 0), "↳", (f'(s) < 0) ∧ (f''(s) < 0), "⤵"], s, Sequence[(Element[Zip[x(s), s, Unique[Sort[Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}], Zip[x(s), s, Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}]]]]], t] + Element[Zip[x(s), s, Unique[Sort[Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}], Zip[x(s), s, Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}]]]]], t + 1]) / 2, t, 1, Length[Zip[x(s), s, Unique[Sort[Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}], Zip[x(s), s, Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}]]]]]] - 1]]}], Join[{Zip[x(s), s, Unique[Sort[Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}], Zip[x(s), s, Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}]]]]], Sequence[(Element[Zip[x(s), s, Unique[Sort[Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}], Zip[x(s), s, Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}]]]]], t] + Element[Zip[x(s), s, Unique[Sort[Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}], Zip[x(s), s, Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}]]]]], t + 1]) / 2, t, 1, Length[Zip[x(s), s, Unique[Sort[Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}], Zip[x(s), s, Flatten[{(min, f(min ) ), (max, f(max ) ), Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f'(x), x - x, min, max]}]], Zip[(x(s), f(x(s ) ) ), s, RemoveUndefined[{Intersect[f''(x), x - x, min, max]}]]}]]]]]] - 1]}]]]}, "c_|h"]

 

On Update スクリプトで点の動きを制御する

設問

GeoGebraで、自由な点オブジェクトAを作成した。
いま、点AのOn Update スクリプトを記述することで、点Aの挙動を以下のように制御したい。そのためのスクリプトを記述しなさい。ただし、点Aを、他のオブジェクトの従属オブジェクトとして再定義することは認めない。

(1)単位円周上だけを動き、かつ偏角が整数度になるようにする。

(2)Angle[A]が整数度になるようにする。

(3)y=sin(x)のグラフ上だけを動くようにする。

(4)y=2xのグラフ上だけを動くようにする。

(5)単位円の内部だけを動くようにする。

(6)単位円の外部だけを動くようにする。

(7)格子点上だけを動くようにする。

(8)x座標、y座標ともに、0.1刻みで動くようにする。

(9)原則として自由に動けるが、ある格子点に近づいたとき(具体的には、当該格子点との距離が0.1以下になったとき)には、当該格子点に吸い付くようにする。

解答例

続きを読む