牛顿法求函数根的几何演示
2014-10-31 14:22
本范例演示了牛顿法求解函数方程根的迭代过程。通过可视化函数图像及其切线,展示了如何利用切线与x轴的交点逐步逼近函数的真实根。用户可以调整初始点,观察迭代序列的收敛情况,直观理解微积分中导数与切线在数值分析中的应用。
所属专题
微积分
GeoGebra 画板及绘图内容加载中,请稍等……
<?xml version="1.0" encoding="utf-8"?>
<geogebra format="5.0" version="5.0.17.0" id="e61d1204-774f-457f-84c3-1090c235b9c0" xsi:noNamespaceSchemaLocation="http://www.geogebra.org/ggb.xsd" xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<gui>
<window width="967" height="700" />
<perspectives>
<perspective id="tmp">
<panes>
<pane location="" divider="0.7094105480868665" orientation="1" />
<pane location="0" divider="0.10341261633919338" orientation="1" />
</panes>
<views>
<view id="4097" visible="false" inframe="true" stylebar="true" location="1,1,1,1" size="400" window="740,350,700,550" />
<view id="512" toolbar="0 | 1 501 5 19 , 67 | 2 15 45 18 , 7 37 | 514 3 9 , 13 44 , 47 | 16 | 551 550 11 , 22 , 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="1" visible="true" inframe="false" stylebar="false" location="3,1" size="686" 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="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="2" visible="false" inframe="false" stylebar="false" location="3" size="200" window="100,100,250,400" />
<view id="16" visible="true" inframe="false" stylebar="false" location="1" size="261" 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" visible="false" inframe="true" stylebar="true" location="1" size="150" window="50,50,500,500" />
<view id="70" toolbar="0 || 2020 || 2021 || 2022" visible="false" inframe="true" stylebar="true" location="1" size="150" window="50,50,500,500" />
</views>
<toolbar show="true" items="0 39 | 1 501 67 , 5 19 , 72 | 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 | 30 29 54 32 31 33 | 17 26 62 73 , 14 68 | 25 52 60 61 | 40 41 42 , 27 28 35 , 6" position="1" help="true" />
<input show="true" cmd="true" top="false" />
<dockBar show="true" east="true" />
</perspective>
</perspectives>
<labelingStyle val="2"/>
<font size="12"/>
<graphicsSettings javaLatexFonts="false"/>
</gui>
<euclidianView>
<size width="686" height="571"/>
<coordSystem xZero="175.59157076019395" yZero="355.0422006266648" scale="46.667801465063846" yscale="46.66780146506385"/>
<evSettings axes="true" grid="false" gridIsBold="false" pointCapturing="0" rightAngleStyle="2" checkboxSize="26" gridType="0"/>
<bgColor r="255" g="255" b="255"/>
<axesColor r="0" g="0" b="0"/>
<gridColor r="192" g="192" b="192"/>
<lineStyle axes="0" grid="10"/>
<axis id="0" show="true" label="" unitLabel="" tickStyle="1" showNumbers="true"/>
<axis id="1" show="false" label="" unitLabel="" tickStyle="1" showNumbers="true"/>
</euclidianView>
<euclidianView>
<viewNumber viewNo="2"/>
<size width="261" height="571"/>
<coordSystem xZero="215.0" yZero="315.00000000000006" scale="50.0" yscale="50.00000000000001"/>
<evSettings axes="false" grid="false" gridIsBold="false" pointCapturing="3" rightAngleStyle="2" checkboxSize="26" gridType="0"/>
<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="10"/>
<axis id="0" show="false" label="" unitLabel="" tickStyle="1" showNumbers="true"/>
<axis id="1" show="false" label="" unitLabel="" tickStyle="1" showNumbers="true"/>
</euclidianView>
<kernel>
<continuous val="false"/>
<usePathAndRegionParameters val="true"/>
<decimals val="2"/>
<angleUnit val="degree"/>
<algebraStyle val="0"/>
<coordStyle val="0"/>
<angleFromInvTrig val="false"/>
<startAnimation val="true"/>
</kernel>
<scripting blocked="false" disabled="false"/>
<euclidianView3D>
<coordSystem xZero="0.0" yZero="0.0" zZero="-1.5" scale="50.0" xAngle="20.0" zAngle="-60.0"/>
<evSettings axes="true" grid="false" gridIsBold="false" pointCapturing="3" gridType="0"/>
<axis id="0" show="true" label="" unitLabel="" tickStyle="1" showNumbers="true"/>
<axis id="1" show="true" label="" unitLabel="" tickStyle="1" showNumbers="true"/>
<axis id="2" show="true" label="" unitLabel="" tickStyle="1" showNumbers="true"/>
<plate show="true"/>
<bgColor r="255" g="255" b="255"/>
<clipping use="true" show="true" size="1"/>
<projection type="0"/>
</euclidianView3D>
<construction title="" author="" date="">
<expression label ="f2" exp="f2(x) = x^(2) / 5 - 1 / 2"/>
<element type="function" label="f2">
<show object="false" label="false"/>
<objColor r="0" g="0" b="0" alpha="0.0"/>
<layer val="0"/>
<labelMode val="0"/>
<animation step="0.1" speed="1" type="0" playing="false"/>
<ggbscript onUpdate="f(x) = f2(x)"/>
<lineStyle thickness="2" type="0" typeHidden="1"/>
</element>
<element type="numeric" label="n">
<value val="3.0"/>
<show object="false" label="true"/>
<objColor r="0" g="0" b="0" alpha="0.1"/>
<layer val="0"/>
<labelMode val="1"/>
<slider min="2" max="10" absoluteScreenLocation="true" width="200.0" x="30.0" y="50.0" fixed="false" horizontal="true"/>
<lineStyle thickness="2" type="0" typeHidden="1"/>
<animation step="1" speed="1" type="0" playing="false"/>
</element>
<expression label="xmin" exp="x(Corner[1])" />
<element type="numeric" label="xmin">
<value val="-3.7840130714619757"/>
<objColor r="0" g="0" b="0" alpha="0.1"/>
</element>
<expression label="xmax" exp="x(Corner[2])" />
<element type="numeric" label="xmax">
<value val="10.958485576455823"/>
<objColor r="0" g="0" b="0" alpha="0.1"/>
</element>
<expression label="ymin" exp="y(Corner[1])" />
<element type="numeric" label="ymin">
<value val="-4.648982651041591"/>
<objColor r="0" g="0" b="0" alpha="0.1"/>
</element>
<expression label="ymax" exp="y(Corner[4])" />
<element type="numeric" label="ymax">
<value val="7.629290205436456"/>
<objColor r="0" g="0" b="0" alpha="0.1"/>
</element>
<element type="button" label="setNewPoints">
<show object="true" label="true" ev="3"/>
<objColor r="0" g="0" b="0" alpha="0.0"/>
<layer val="0"/>
<labelOffset x="58" y="436"/>
<labelMode val="0"/>
<animation step="1" speed="1" type="0" playing="false"/>
<auxiliary val="true"/>
<javascript val="// get ggb object var ggb = ggbApplet; // get info from ggb var n = ggb.getValue('n'); var newN = ggb.getValue('newN'); var xmin = ggb.getValue('xmin'); var xmax = ggb.getValue('xmax'); var ymin = ggb.getValue('ymin'); var ymax = ggb.getValue('ymax'); // common variables var objName, x, y, i, cmd; // prepare points if(newN > n){ // add more points if necessary for(i=n+1; i<=newN; i++){ // command to add new point objName = 'P'+i; x = rnd(xmin, xmax); y = rnd(ymin, ymax); cmd = objName + '=('+ x +','+ y +')'; if(!ggb.exists(objName)){ // if point not exist, create it ggb.evalCommand(cmd); } else { // already exist, show it ggb.setVisible(objName, true); } } } else { // newN <= n // hide extra points for(i=newN+1; i<=n; i++){ objName = 'P'+i; ggb.setVisible(objName, false); } } // update n ggb.setValue('n', newN); // set f(x) ggb.evalCommand('f(x) = Polynomial[ps]');"/>
<font serif="false" sizeM="2.0" size="12" style="0"/>
<caption val="使用控制點"/>
</element>
<element type="numeric" label="newN">
<value val="3.0"/>
<show object="true" label="true" ev="3"/>
<objColor r="0" g="0" b="0" alpha="0.1"/>
<layer val="0"/>
<labelOffset x="-58" y="-5"/>
<labelMode val="3"/>
<slider min="2" max="10" absoluteScreenLocation="true" width="100.0" x="89.0" y="336.0" fixed="false" horizontal="true"/>
<lineStyle thickness="2" type="0" typeHidden="1"/>
<animation step="1" speed="1" type="0" playing="false"/>
<caption val="多項式次數 = %v"/>
</element>
<element type="point" label="P0">
<show object="false" label="false"/>
<objColor r="0" g="0" b="255" alpha="0.0"/>
<layer val="0"/>
<labelMode val="0"/>
<animation step="0.1" speed="1" type="1" playing="false"/>
<coords x="0.9730141085347555" y="2.057997111746593" z="1.0"/>
<pointSize val="3"/>
<pointStyle val="0"/>
</element>
<element type="point" label="P1">
<show object="false" label="false"/>
<objColor r="0" g="0" b="255" alpha="0.0"/>
<layer val="0"/>
<labelMode val="0"/>
<animation step="0.1" speed="1" type="1" playing="false"/>
<coords x="6.65144745402635" y="-0.29908842789142626" z="1.0"/>
<pointSize val="3"/>
<pointStyle val="0"/>
</element>
<element type="point" label="P2">
<show object="false" label="false"/>
<objColor r="0" g="0" b="255" alpha="0.0"/>
<layer val="0"/>
<labelMode val="0"/>
<animation step="0.1" speed="1" type="1" playing="false"/>
<coords x="8.02" y="0.62" z="1.0"/>
<pointSize val="3"/>
<pointStyle val="0"/>
</element>
<element type="point" label="P3">
<show object="false" label="false"/>
<objColor r="0" g="0" b="255" alpha="0.0"/>
<layer val="0"/>
<labelMode val="0"/>
<animation step="0.1" speed="1" type="1" playing="false"/>
<coords x="10.74" y="1.74" z="1.0"/>
<pointSize val="3"/>
<pointStyle val="0"/>
</element>
<command name="Sequence">
<input a0="Object["P" + (k)]" a1="k" a2="0" a3="n"/>
<output a0="ps"/>
</command>
<element type="list" label="ps">
<show object="false" label="false"/>
<objColor r="0" g="100" b="0" alpha="0.0"/>
<layer val="0"/>
<labelMode val="0"/>
<selectionAllowed val="false"/>
<lineStyle thickness="2" type="0" typeHidden="1"/>
<pointSize val="3"/>
<pointStyle val="-1"/>
</element>
<element type="point" label="P4">
<show object="false" label="false"/>
<objColor r="0" g="0" b="255" alpha="0.0"/>
<layer val="0"/>
<labelMode val="0"/>
<animation step="0.1" speed="1" type="1" playing="false"/>
<coords x="-0.7" y="1.14" z="1.0"/>
<pointSize val="3"/>
<pointStyle val="0"/>
</element>
<element type="point" label="P5">
<show object="false" label="false"/>
<objColor r="0" g="0" b="255" alpha="0.0"/>
<layer val="0"/>
<labelMode val="0"/>
<animation step="0.1" speed="1" type="1" playing="false"/>
<coords x="1.6587117200658157" y="2.422273967872469" z="1.0"/>
<pointSize val="3"/>
<pointStyle val="0"/>
</element>
<element type="point" label="P6">
<show object="false" label="false"/>
<objColor r="0" g="0" b="255" alpha="0.0"/>
<layer val="0"/>
<labelMode val="0"/>
<animation step="0.1" speed="1" type="1" playing="false"/>
<coords x="-2.0" y="3.0" z="1.0"/>
<pointSize val="3"/>
<pointStyle val="0"/>
</element>
<element type="point" label="P7">
<show object="false" label="false"/>
<objColor r="0" g="0" b="255" alpha="0.0"/>
<layer val="0"/>
<labelMode val="0"/>
<animation step="1" speed="1" type="1" playing="false"/>
<coords x="5.087558834516795" y="7.908615409423168" z="1.0"/>
<pointSize val="3"/>
<pointStyle val="0"/>
</element>
<element type="numeric" label="m">
<value val="2.0"/>
<show object="true" label="true"/>
<objColor r="0" g="0" b="0" alpha="0.1"/>
<layer val="0"/>
<labelOffset x="-41" y="-5"/>
<labelMode val="3"/>
<slider min="1" max="6" absoluteScreenLocation="true" width="100.0" x="97.0" y="497.0" fixed="false" horizontal="true"/>
<lineStyle thickness="2" type="0" typeHidden="1"/>
<animation step="1" speed="0.5" type="1" playing="true"/>
<caption val="迭代次數 = %v"/>
</element>
<expression label="f" exp="f2" />
<element type="function" label="f">
<show object="true" label="false"/>
<objColor r="0" g="0" b="255" alpha="0.0"/>
<layer val="0"/>
<labelMode val="0"/>
<selectionAllowed val="false"/>
<lineStyle thickness="2" type="0" typeHidden="1"/>
</element>
<expression label="g" exp="g(x) = x - f(x) / f'(x)" />
<element type="function" label="g">
<show object="false" label="false"/>
<objColor r="0" g="0" b="0" alpha="0.0"/>
<layer val="0"/>
<labelMode val="0"/>
<lineStyle thickness="2" type="0" typeHidden="1"/>
</element>
<command name="Point">
<input a0="xAxis"/>
<output a0="A"/>
</command>
<element type="point" label="A">
<show object="true" label="false"/>
<objColor r="125" g="125" b="255" alpha="0.0"/>
<layer val="0"/>
<labelMode val="0"/>
<animation step="0.1" speed="1" type="1" playing="false"/>
<coords x="6.0300339935763265" y="0.0" z="1.0"/>
<pointSize val="6"/>
<pointStyle val="0"/>
</element>
<element type="boolean" label="showControlPoints">
<value val="false"/>
<show object="true" label="true" ev="3"/>
<objColor r="0" g="0" b="0" alpha="0.0"/>
<layer val="0"/>
<labelOffset x="53" y="369"/>
<labelMode val="0"/>
<javascript onUpdate="var ggb = ggbApplet; var n = ggb.getValue('n'); var showPoints = (ggb.getValue('showControlPoints')===1); for(var i=0; i<=n; i++){ var objName = 'P'+i; ggb.setVisible(objName, showPoints); }"/>
<caption val="顯示控制點"/>
</element>
<command name="IterationList">
<input a0="g" a1="x(A)" a2="m"/>
<output a0="xs"/>
</command>
<element type="list" label="xs">
<objColor r="0" g="100" b="0" alpha="0.1"/>
<selectionAllowed val="false"/>
<lineStyle thickness="2" type="0" typeHidden="1"/>
<pointSize val="3"/>
<pointStyle val="-1"/>
</element>
<expression label="ys" exp="f(xs)" />
<element type="list" label="ys">
<objColor r="0" g="100" b="0" alpha="0.1"/>
<selectionAllowed val="false"/>
<lineStyle thickness="2" type="0" typeHidden="1"/>
<pointSize val="3"/>
<pointStyle val="-1"/>
</element>
<command name="Sequence">
<input a0="(Element[xs, k], Element[ys, k])" a1="k" a2="1" a3="m"/>
<output a0="qs"/>
</command>
<element type="list" label="qs">
<show object="true" label="false"/>
<objColor r="255" g="255" b="0" alpha="0.0"/>
<layer val="1"/>
<labelMode val="0"/>
<selectionAllowed val="false"/>
<lineStyle thickness="2" type="0" typeHidden="1"/>
<pointSize val="3"/>
<pointStyle val="-1"/>
</element>
<command name="Sequence">
<input a0="Segment[Element[qs, k], (Element[xs, k], 0)]" a1="k" a2="1" a3="m"/>
<output a0="segsX"/>
</command>
<element type="list" label="segsX">
<show object="true" label="false"/>
<objColor r="255" g="0" b="0" alpha="0.0"/>
<layer val="0"/>
<labelMode val="0"/>
<selectionAllowed val="false"/>
<lineStyle thickness="2" type="0" typeHidden="1"/>
<pointSize val="3"/>
<pointStyle val="-1"/>
</element>
<command name="Sequence">
<input a0="Segment[Element[qs, k], (Element[xs, k + 1], 0)]" a1="k" a2="1" a3="m"/>
<output a0="segsTangent"/>
</command>
<element type="list" label="segsTangent">
<show object="true" label="false"/>
<objColor r="255" g="0" b="0" alpha="0.0"/>
<layer val="0"/>
<labelMode val="0"/>
<selectionAllowed val="false"/>
<lineStyle thickness="2" type="0" typeHidden="1"/>
<pointSize val="3"/>
<pointStyle val="-1"/>
</element>
<command name="Textfield">
<input a0="f2"/>
<output a0="inputBox1"/>
</command>
<element type="textfield" label="inputBox1">
<show object="true" label="true" ev="3"/>
<objColor r="0" g="0" b="0" alpha="0.0"/>
<layer val="0"/>
<labelOffset x="29" y="117"/>
<labelMode val="0"/>
<animation step="1" speed="1" type="0" playing="false"/>
<auxiliary val="true"/>
<linkedGeo exp="f2"/>
<length val="15"/>
<caption val="["/>
</element>
<element type="image" label="pic1">
<file name="23dc8a7ec355f42858d1e43205955d3c/002.png"/>
<inBackground val="false"/>
<absoluteScreenLocation x="15" y="52"/> <show object="true" label="false" ev="3"/>
<objColor r="0" g="0" b="0" alpha="1.0"/>
<layer val="0"/>
<labelMode val="0"/>
<animation step="1" speed="1" type="0" playing="false"/>
</element>
<element type="image" label="pic2">
<file name="1d553f9eccd67134e540ccea5d0a8bbe/003.png"/>
<inBackground val="false"/>
<absoluteScreenLocation x="69" y="102"/> <show object="true" label="false" ev="3"/>
<objColor r="0" g="0" b="0" alpha="1.0"/>
<layer val="0"/>
<labelMode val="0"/>
<animation step="1" speed="1" type="0" playing="false"/>
</element>
<element type="image" label="pic3">
<file name="0a3db8cc7b75c328d946ee57c90e9f34/004.png"/>
<inBackground val="false"/>
<absoluteScreenLocation x="66" y="284"/> <show object="true" label="false" ev="3"/>
<objColor r="0" g="0" b="0" alpha="1.0"/>
<layer val="0"/>
<labelMode val="0"/>
<animation step="1" speed="1" type="0" playing="false"/>
</element>
<element type="image" label="pic4">
<file name="00700385eae51ae40e583a55cc81058a/n1.png"/>
<inBackground val="false"/>
<absoluteScreenLocation x="19" y="106"/> <show object="true" label="false" ev="3"/>
<objColor r="0" g="0" b="0" alpha="1.0"/>
<layer val="0"/>
<labelMode val="0"/>
<animation step="1" speed="1" type="0" playing="false"/>
</element>
<element type="image" label="pic5">
<file name="4f6fc314b6f2c86467301f022b0a3a8d/n2.png"/>
<inBackground val="false"/>
<absoluteScreenLocation x="18" y="286"/> <show object="true" label="false" ev="3"/>
<objColor r="0" g="0" b="0" alpha="1.0"/>
<layer val="0"/>
<labelMode val="0"/>
<animation step="1" speed="1" type="0" playing="false"/>
</element>
<element type="image" label="pic6">
<file name="604b37af28324ccad3d95adbe5638caa/or.png"/>
<inBackground val="false"/>
<absoluteScreenLocation x="18" y="217"/> <show object="true" label="false" ev="3"/>
<objColor r="0" g="0" b="0" alpha="1.0"/>
<layer val="0"/>
<labelMode val="0"/>
<animation step="1" speed="1" type="0" playing="false"/>
</element>
<expression label="Xn" exp="(Element[xs, m + 1], 0)" type="point" />
<element type="point" label="Xn">
<show object="true" label="false"/>
<objColor r="255" g="0" b="0" alpha="0.0"/>
<layer val="2"/>
<labelMode val="0"/>
<coords x="1.9990764833223686" y="0.0" z="1.0"/>
<pointSize val="3"/>
<pointStyle val="1"/>
</element>
<expression label="text2" exp=""x_0=" + (LaTeX[x(A)]) + """ />
<element type="text" label="text2">
<show object="true" label="false"/>
<objColor r="0" g="0" b="255" alpha="0.0"/>
<layer val="0"/>
<labelMode val="0"/>
<isLaTeX val="true"/>
<font serif="true" sizeM="1.4" size="5" style="1"/>
<startPoint exp="A"/>
<labelOffset x="-35" y="20"/>
</element>
<command name="Vector">
<input a0="Xn + (0, (-0.8))" a1="Xn + (0, (-0.3))"/>
<output a0="arr"/>
</command>
<element type="vector" label="arr">
<show object="true" label="false"/>
<objColor r="255" g="0" b="0" alpha="0.0"/>
<layer val="0"/>
<labelMode val="0"/>
<coords x="0.0" y="0.5" z="0.0"/>
<lineStyle thickness="2" type="0" typeHidden="1"/>
<coordStyle style="cartesian"/>
<startPoint x="1.9990764833223686" y="-0.8" z="1.0"/>
</element>
<expression label="Xn2" exp="Xn" type="point" />
<element type="point" label="Xn2">
<show object="true" label="false"/>
<objColor r="255" g="255" b="0" alpha="0.0"/>
<layer val="1"/>
<labelMode val="0"/>
<coords x="1.9990764833223686" y="0.0" z="1.0"/>
<pointSize val="4"/>
<pointStyle val="0"/>
</element>
<expression label="text1" exp=""x_{" + (LaTeX[m]) + "}=" + (LaTeX[x(Xn)]) + """ />
<element type="text" label="text1">
<show object="true" label="false"/>
<objColor r="255" g="0" b="0" alpha="0.0"/>
<layer val="0"/>
<labelMode val="0"/>
<isLaTeX val="true"/>
<font serif="true" sizeM="1.4" size="5" style="1"/>
<startPoint exp="Xn + (0, -1)"/>
<labelOffset x="-32" y="-3"/>
</element>
<element type="button" label="button1">
<show object="true" label="true"/>
<objColor r="0" g="0" b="0" alpha="1.0"/>
<layer val="2"/>
<labelOffset x="217" y="485"/>
<labelMode val="0"/>
<animation step="1" speed="1" type="0" playing="false"/>
<auxiliary val="true"/>
<ggbscript val="m=1 StartAnimation[m, true]"/>
<font serif="false" sizeM="2.0" size="12" style="0"/>
<file name="/geogebra/main/nav_play.png"/>
</element>
<element type="button" label="button2">
<show object="true" label="true"/>
<objColor r="0" g="0" b="0" alpha="1.0"/>
<layer val="2"/>
<labelOffset x="268" y="486"/>
<labelMode val="0"/>
<animation step="1" speed="1" type="0" playing="false"/>
<auxiliary val="true"/>
<ggbscript val="StartAnimation[m, false]"/>
<font serif="false" sizeM="2.0" size="12" style="0"/>
<file name="/geogebra/main/nav_pause.png"/>
</element>
</construction>
</geogebra>