Interactive Piecewise and Nested Function Calculation Demo
2020-03-10 00:06
This GeoGebra example demonstrates the definition, evaluation, and visualization of piecewise and nested functions. Users can customize function expressions via input boxes, with the system computing and displaying function values in real time. The example integrates geometric construction elements (points, segments, circle arcs, intersections) with algebraic computation, supporting interactive in
In collections
Secondary Vocational Mathematics
<?xml version="1.0" encoding="utf-8"?>
<geogebra format="5.0" version="5.0.574.0" app="classic" platform="w" id="862dfc40-9f38-4a58-b4b9-0c44d6350b36" xsi:noNamespaceSchemaLocation="http://www.geogebra.org/apps/xsd/ggb.xsd" xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<gui>
<window width="1350" height="561" />
<perspectives>
<perspective id="tmp">
<panes>
<pane location="" divider="0.6125925925925926" orientation="1" />
</panes>
<views>
<view id="512" toolbar="0 | 1 501 5 19 , 67 | 2 15 45 18 , 7 37 | 514 3 9 , 13 44 , 47 | 16 51 | 551 550 11 , 20 22 21 23 , 55 56 57 , 12 | 69 | 510 511 , 512 513 | 533 531 , 534 532 , 522 523 , 537 536 , 535 | 521 520 | 36 , 38 49 560 | 571 30 29 570 31 33 | 17 | 540 40 41 42 , 27 28 35 , 6 , 502" visible="false" inframe="false" stylebar="false" location="1,1,1" size="500" window="100,100,600,400" />
<view id="4" toolbar="0 || 2020 , 2021 , 2022 , 66 || 2001 , 2003 , 2002 , 2004 , 2005 || 2040 , 2041 , 2042 , 2044 , 2043" visible="false" inframe="false" stylebar="false" location="1,1" size="300" window="100,100,600,400" />
<view id="2" visible="false" inframe="false" stylebar="false" location="3,3" size="200" window="100,100,600,400" />
<view id="8" toolbar="1001 | 1002 | 1003 || 1005 | 1004 || 1006 | 1007 | 1010 || 1008 1009 || 66 68 || 6" visible="false" inframe="false" stylebar="false" location="1,3" size="300" window="100,100,600,400" />
<view id="4097" visible="false" inframe="false" stylebar="true" location="1,1" size="273" window="100,100,700,550" />
<view id="1" visible="true" inframe="false" stylebar="true" location="3" size="827" window="100,100,600,400" />
<view id="16" visible="true" inframe="false" stylebar="true" location="1" size="515" window="50,50,500,500" />
<view id="32" visible="false" inframe="false" stylebar="true" location="1" size="150" window="50,50,500,500" />
<view id="64" toolbar="0" visible="false" inframe="false" stylebar="false" location="1" size="150" window="50,50,500,500" />
<view id="128" visible="false" inframe="false" stylebar="false" location="1" size="480" window="50,50,500,500" />
<view id="70" toolbar="0 || 2020 || 2021 || 2022" visible="false" inframe="false" stylebar="true" location="1" size="150" window="50,50,500,500" />
<view id="43" visible="false" inframe="false" stylebar="false" location="1" size="450" window="50,50,500,500" />
</views>
<toolbar show="false" items="0 39 73 62 | 1 501 67 , 5 19 , 72 75 76 | 2 15 45 , 18 65 , 7 37 | 4 3 8 9 , 13 44 , 58 , 47 | 16 51 64 , 70 | 10 34 53 11 , 24 20 22 , 21 23 | 55 56 57 , 12 | 36 46 , 38 49 50 , 71 14 68 | 30 29 54 32 31 33 | 25 17 26 60 52 61 | 40 41 42 , 27 28 35 , 6" position="1" help="false" />
<input show="false" cmd="true" top="algebra" />
<dockBar show="false" east="false" />
</perspective>
</perspectives>
<labelingStyle val="0"/>
<font size="12"/>
</gui>
<euclidianView>
<viewNumber viewNo="1"/>
<size width="827" height="561"/>
<coordSystem xZero="293.11854750907173" yZero="460.4593887448983" scale="161.56784145680479" yscale="161.5678414568051"/>
<evSettings axes="true" grid="false" gridIsBold="false" pointCapturing="3" rightAngleStyle="1" checkboxSize="26" gridType="3"/>
<bgColor r="255" g="255" b="255"/>
<axesColor r="0" g="0" b="0"/>
<gridColor r="192" g="192" b="192"/>
<lineStyle axes="1" grid="0"/>
<axis id="0" show="true" label="" unitLabel="" tickStyle="1" showNumbers="true"/>
<axis id="1" show="true" label="" unitLabel="" tickStyle="1" showNumbers="true"/>
</euclidianView>
<euclidianView>
<viewNumber viewNo="2"/>
<size width="515" height="561"/>
<coordSystem xZero="224.00511363636383" yZero="294.9130681818182" scale="50.08522727272736" yscale="50.08522727272725"/>
<evSettings axes="false" grid="false" gridIsBold="false" pointCapturing="3" rightAngleStyle="1" checkboxSize="26" gridType="3"/>
<bgColor r="255" g="255" b="255"/>
<axesColor r="0" g="0" b="0"/>
<gridColor r="192" g="192" b="192"/>
<lineStyle axes="1" grid="0"/>
<axis id="0" show="false" label="" unitLabel="" tickStyle="1" showNumbers="true"/>
<axis id="1" show="false" label="" unitLabel="" tickStyle="1" showNumbers="true"/>
</euclidianView>
<kernel>
<uses3D val="true"/>
<continuous val="false"/>
<usePathAndRegionParameters val="true"/>
<decimals val="2"/>
<angleUnit val="degree"/>
<algebraStyle val="0" spreadsheet="0"/>
<coordStyle val="0"/>
</kernel>
<tableview min="-2" max="2" step="1"/>
<scripting blocked="false" disabled="false"/>
<construction title="" author="" date="">
<element type="numeric" label="a">
<value val="1"/>
<show object="true" label="true" ev="3"/>
<objColor r="0" g="0" b="0" alpha="0.10000000149011612"/>
<layer val="0"/>
<labelOffset x="0" y="6"/>
<labelMode val="3"/>
<slider min="-5" max="5" absoluteScreenLocation="true" width="130" x="204" y="210" fixed="true" horizontal="true" showAlgebra="true"/>
<lineStyle thickness="10" type="0" typeHidden="1"/>
<animation step="0.01" speed="1" type="0" playing="false"/>
<caption val="$x=%v$"/>
</element>
<expression label="q" exp="q(x) = (-x) + 3" type="function"/>
<element type="function" label="q">
<show object="false" label="true" ev="4"/>
<objColor r="153" g="51" b="0" alpha="0"/>
<layer val="0"/>
<labelMode val="0"/>
<fixed val="true"/>
<lineStyle thickness="5" type="0" typeHidden="1" opacity="178"/>
</element>
<expression label="p" exp="p(x) = x^(2) + 1" type="function"/>
<element type="function" label="p">
<show object="false" label="true" ev="4"/>
<objColor r="102" g="102" b="102" alpha="0"/>
<layer val="0"/>
<labelMode val="0"/>
<fixed val="true"/>
<lineStyle thickness="5" type="0" typeHidden="1" opacity="178"/>
</element>
<expression label="f" exp="f(x) = If[x < a, p(x), q(x)]" />
<element type="function" label="f">
<show object="true" label="true" ev="4"/>
<objColor r="0" g="100" b="0" alpha="0"/>
<layer val="0"/>
<labelMode val="0"/>
<fixed val="true"/>
<lineStyle thickness="7" type="0" typeHidden="1" opacity="178"/>
</element>
<command name="Point">
<input a0="xAxis"/>
<output a0="A"/>
</command>
<element type="point" label="A">
<show object="true" label="true" ev="4"/>
<objColor r="255" g="0" b="0" alpha="0"/>
<layer val="0"/>
<labelMode val="3"/>
<animation step="0.1" speed="1" type="1" playing="false"/>
<coords x="-1" y="0" z="1"/>
<pointSize val="5"/>
<pointStyle val="0"/>
<caption val="$\large 拖动我$"/>
</element>
<expression label="vx" exp="x(A)" />
<element type="numeric" label="vx">
<value val="-1"/>
<objColor r="0" g="0" b="0" alpha="0.10000000149011612"/>
</element>
<command name="Text">
<input a0="x(A)" a1="(x(A), -0.3)" a2="true" a3="false"/>
<output a0="text2"/>
</command>
<element type="text" label="text2">
<show object="true" label="true" ev="8"/>
<objColor r="0" g="0" b="0" alpha="0"/>
<layer val="0"/>
<labelMode val="0"/>
<font serif="true" sizeM="2" size="12" style="1"/>
<startPoint x="-1" y="-0.3" z="1"/>
</element>
<command name="Textfield">
<input a0="p"/>
<output a0="InputBox表达式1"/>
</command>
<element type="textfield" label="InputBox表达式1">
<show object="true" label="true" ev="3"/>
<objColor r="0" g="0" b="0" alpha="0"/>
<layer val="0"/>
<labelOffset x="83" y="91"/>
<labelMode val="3"/>
<fixed val="true"/>
<auxiliary val="true"/>
<font serif="false" sizeM="2" size="12" style="0"/>
<length val="8"/>
<caption val="第一段:"/>
</element>
<command name="Textfield">
<input a0="q"/>
<output a0="InputBox表达式2"/>
</command>
<element type="textfield" label="InputBox表达式2">
<show object="true" label="true" ev="3"/>
<objColor r="0" g="0" b="0" alpha="0"/>
<layer val="0"/>
<labelOffset x="83" y="135"/>
<labelMode val="3"/>
<fixed val="true"/>
<auxiliary val="true"/>
<font serif="false" sizeM="2" size="12" style="0"/>
<length val="8"/>
<caption val="第二段:"/>
</element>
<expression label="text1" exp=""f(x)= \begin{cases}{ } " + (LaTeX[p]) + " & ,x<" + (LaTeX[a]) + " \\ " + (LaTeX[q]) + "&,x>=" + (LaTeX[a]) + " \end{cases} "" />
<element type="text" label="text1">
<show object="true" label="true" ev="11"/>
<objColor r="128" g="0" b="128" alpha="0"/>
<layer val="0"/>
<labelMode val="0"/>
<fixed val="true"/>
<isLaTeX val="true"/>
<font serif="true" sizeM="2" size="12" style="1"/>
<absoluteScreenLocation x="56" y="233"/>
</element>
<expression label="B" exp="(x(A), f(x(A)))" type="point" />
<element type="point" label="B">
<show object="true" label="true" ev="4"/>
<objColor r="255" g="0" b="0" alpha="0"/>
<layer val="0"/>
<labelMode val="0"/>
<coords x="-1" y="2" z="1"/>
<pointSize val="4"/>
<pointStyle val="0"/>
</element>
<expression label="C" exp="(0, f(x(A)))" type="point" />
<element type="point" label="C">
<show object="true" label="true" ev="4"/>
<objColor r="255" g="0" b="0" alpha="0"/>
<layer val="0"/>
<labelMode val="0"/>
<coords x="0" y="2" z="1"/>
<pointSize val="4"/>
<pointStyle val="0"/>
</element>
<command name="Segment">
<input a0="A" a1="B"/>
<output a0="g"/>
</command>
<element type="segment" label="g">
<show object="true" label="false" ev="4"/>
<objColor r="255" g="0" b="0" alpha="0"/>
<layer val="0"/>
<labelMode val="0"/>
<coords x="-2" y="0" z="-2"/>
<lineStyle thickness="5" type="10" typeHidden="1" opacity="178"/>
<outlyingIntersections val="false"/>
<keepTypeOnTransform val="true"/>
</element>
<command name="Segment">
<input a0="B" a1="C"/>
<output a0="h"/>
</command>
<element type="segment" label="h">
<show object="true" label="false" ev="4"/>
<objColor r="255" g="0" b="0" alpha="0"/>
<layer val="0"/>
<labelMode val="0"/>
<coords x="0" y="1" z="-2"/>
<lineStyle thickness="5" type="10" typeHidden="1" opacity="178"/>
<outlyingIntersections val="false"/>
<keepTypeOnTransform val="true"/>
</element>
<expression label="b" exp="f(vx)" />
<element type="numeric" label="b">
<value val="2"/>
<objColor r="0" g="0" b="0" alpha="0.10000000149011612"/>
</element>
<expression label="text3" exp=""分段位置:""/>
<element type="text" label="text3">
<show object="true" label="true" ev="43"/>
<objColor r="0" g="0" b="0" alpha="0"/>
<layer val="0"/>
<labelMode val="0"/>
<fixed val="true"/>
<font serif="false" sizeM="2" size="12" style="0"/>
<absoluteScreenLocation x="81" y="214"/>
</element>
<command name="Textfield">
<input a0="b"/>
<output a0="InputBox计算函数值"/>
</command>
<element type="textfield" label="InputBox计算函数值">
<show object="true" label="true" ev="3"/>
<objColor r="255" g="0" b="0" alpha="1"/>
<layer val="0"/>
<labelOffset x="88" y="349"/>
<labelMode val="3"/>
<fixed val="true"/>
<auxiliary val="true"/>
<font serif="false" sizeM="2" size="12" style="0"/>
<length val="8"/>
<caption val="函数值:"/>
</element>
<expression label="text5" exp=""分段函数与函数嵌套计算""/>
<element type="text" label="text5">
<show object="true" label="true" ev="43"/>
<objColor r="255" g="255" b="0" alpha="0"/>
<bgColor r="255" g="127" b="0" alpha="255"/>
<layer val="0"/>
<labelMode val="0"/>
<fixed val="true"/>
<isLaTeX val="true"/>
<font serif="true" sizeM="2" size="12" style="1"/>
<absoluteScreenLocation x="51" y="22"/>
</element>
<expression label="text4" exp=""=" + (LaTeX[b]) + """ />
<element type="text" label="text4">
<show object="true" label="true" ev="11"/>
<objColor r="255" g="0" b="0" alpha="0"/>
<layer val="0"/>
<labelMode val="0"/>
<fixed val="true"/>
<isLaTeX val="true"/>
<font serif="true" sizeM="2" size="12" style="1"/>
<absoluteScreenLocation x="344" y="348"/>
</element>
<expression label="c" exp="f(f(vx))" />
<element type="numeric" label="c">
<value val="1"/>
<objColor r="0" g="0" b="0" alpha="0.10000000149011612"/>
</element>
<command name="Textfield">
<input a0="c"/>
<output a0="InputBox1"/>
</command>
<element type="textfield" label="InputBox1">
<show object="true" label="true" ev="3"/>
<condition showObject="e"/>
<objColor r="0" g="0" b="255" alpha="1"/>
<layer val="0"/>
<labelOffset x="40" y="415"/>
<labelMode val="3"/>
<fixed val="true"/>
<auxiliary val="true"/>
<font serif="false" sizeM="2" size="12" style="0"/>
<length val="8"/>
<caption val="嵌套函数值:"/>
</element>
<expression label="text6" exp=""=" + (LaTeX[c]) + """ />
<element type="text" label="text6">
<show object="true" label="true" ev="43"/>
<condition showObject="e"/>
<objColor r="0" g="0" b="255" alpha="0"/>
<layer val="0"/>
<labelMode val="0"/>
<fixed val="true"/>
<isLaTeX val="true"/>
<font serif="true" sizeM="2" size="12" style="1"/>
<absoluteScreenLocation x="345" y="414"/>
</element>
<command name="Text">
<input a0="f(x(A))" a1="(0.1, f(x(A)))" a2="true" a3="false"/>
<output a0="text7"/>
</command>
<element type="text" label="text7">
<show object="true" label="true" ev="8"/>
<objColor r="0" g="0" b="0" alpha="0"/>
<layer val="0"/>
<labelMode val="0"/>
<font serif="false" sizeM="2" size="12" style="1"/>
<startPoint x="0.1" y="2" z="1"/>
</element>
<expression label="D" exp="(f(vx), 0)" type="point" />
<element type="point" label="D">
<show object="true" label="true" ev="4"/>
<condition showObject="e"/>
<objColor r="75" g="0" b="130" alpha="0"/>
<layer val="0"/>
<labelMode val="0"/>
<coords x="2" y="0" z="1"/>
<pointSize val="4"/>
<pointStyle val="0"/>
</element>
<expression label="E" exp="(f(vx), f(f(vx)))" type="point" />
<element type="point" label="E">
<show object="true" label="true" ev="4"/>
<condition showObject="e"/>
<objColor r="75" g="0" b="130" alpha="0"/>
<layer val="0"/>
<labelMode val="0"/>
<coords x="2" y="1" z="1"/>
<pointSize val="4"/>
<pointStyle val="0"/>
</element>
<command name="Intersect">
<input a0="xAxis" a1="yAxis"/>
<output a0="O"/>
</command>
<element type="point" label="O">
<show object="true" label="true" ev="4"/>
<objColor r="68" g="68" b="68" alpha="0"/>
<layer val="0"/>
<labelMode val="0"/>
<coords x="0" y="0" z="1"/>
<pointSize val="4"/>
<pointStyle val="0"/>
</element>
<command name="CircleArc">
<input a0="O" a1="D" a2="C"/>
<output a0="d"/>
</command>
<element type="conicpart" label="d">
<show object="true" label="false" ev="4"/>
<condition showObject="e"/>
<objColor r="128" g="0" b="128" alpha="0"/>
<layer val="0"/>
<labelMode val="0"/>
<lineStyle thickness="5" type="30" typeHidden="1" opacity="178"/>
<eigenvectors x0="1" y0="0" z0="1.0" x1="0" y1="1" z1="1.0"/>
<matrix A0="1" A1="1" A2="-4" A3="0" A4="0" A5="0"/>
<eqnStyle style="implicit"/>
<outlyingIntersections val="false"/>
<keepTypeOnTransform val="true"/>
</element>
<command name="Segment">
<input a0="D" a1="E"/>
<output a0="i"/>
</command>
<element type="segment" label="i">
<show object="true" label="false" ev="4"/>
<condition showObject="e"/>
<objColor r="128" g="0" b="128" alpha="0"/>
<layer val="0"/>
<labelMode val="0"/>
<coords x="-1" y="0" z="2"/>
<lineStyle thickness="5" type="15" typeHidden="1" opacity="178"/>
<outlyingIntersections val="false"/>
<keepTypeOnTransform val="true"/>
</element>
<expression label="F" exp="(0, f(f(vx)))" type="point" />
<element type="point" label="F">
<show object="true" label="true" ev="4"/>
<condition showObject="e"/>
<objColor r="75" g="0" b="130" alpha="0"/>
<layer val="0"/>
<labelMode val="0"/>
<coords x="0" y="1" z="1"/>
<pointSize val="4"/>
<pointStyle val="0"/>
</element>
<command name="Segment">
<input a0="E" a1="F"/>
<output a0="j"/>
</command>
<element type="segment" label="j">
<show object="true" label="false" ev="4"/>
<condition showObject="e"/>
<objColor r="128" g="0" b="128" alpha="0"/>
<layer val="0"/>
<labelMode val="0"/>
<coords x="0" y="-2" z="2"/>
<lineStyle thickness="5" type="15" typeHidden="1" opacity="178"/>
<outlyingIntersections val="false"/>
<keepTypeOnTransform val="true"/>
</element>
<element type="boolean" label="e">
<value val="false"/>
<show object="true" label="true" ev="3"/>
<objColor r="0" g="0" b="0" alpha="0"/>
<layer val="0"/>
<labelOffset x="61" y="478"/>
<labelMode val="0"/>
<checkbox fixed="true"/>
<caption val="嵌套计算图形表示"/>
</element>
</construction>
</geogebra>