Files

54 lines
2.5 KiB
XML

<svg width="380" height="200" xmlns="http://www.w3.org/2000/svg">
<defs>
<marker id="nm-arr" markerWidth="7" markerHeight="5" refX="7" refY="2.5" orient="auto">
<path d="M0,0 L7,2.5 L0,5" fill="#ccc"/>
</marker>
<marker id="nm-r" markerWidth="6" markerHeight="4" refX="6" refY="2" orient="auto">
<path d="M0,0 L6,2 L0,4" fill="#e74c3c"/>
</marker>
</defs>
<text x="190" y="14" text-anchor="middle" fill="#333" font-size="12" font-weight="bold">Newton's method: tangent line finds the root</text>
<!-- Axes -->
<line x1="30" y1="140" x2="370" y2="140" stroke="#ccc" stroke-width="1" marker-end="url(#nm-arr)"/>
<line x1="50" y1="185" x2="50" y2="20" stroke="#ccc" stroke-width="1" marker-end="url(#nm-arr)"/>
<text x="374" y="143" fill="#999" font-size="9">x</text>
<!-- Curve f(x) -->
<path d="M 40,30 Q 80,80 130,130 Q 170,150 210,148 Q 250,140 280,110 Q 310,70 350,25"
fill="none" stroke="#9b59b6" stroke-width="2.5"/>
<text x="352" y="22" fill="#9b59b6" font-size="10">f(x)</text>
<!-- Root (true zero) -->
<circle cx="185" cy="140" r="5" fill="#27ae60"/>
<text x="185" y="158" text-anchor="middle" fill="#27ae60" font-size="10" font-weight="bold">root</text>
<!-- x₀: initial guess -->
<circle cx="310" cy="70" r="4" fill="#e74c3c"/>
<line x1="310" y1="70" x2="310" y2="140" stroke="#e74c3c" stroke-width="0.8" stroke-dasharray="3"/>
<text x="310" y="155" text-anchor="middle" fill="#e74c3c" font-size="9">x₀</text>
<!-- Tangent from x₀ -->
<line x1="180" y1="140" x2="350" y2="30" stroke="#e74c3c" stroke-width="1.5" stroke-dasharray="5,3"/>
<!-- x₁: where tangent crosses x-axis -->
<circle cx="225" cy="140" r="4" fill="#3498db"/>
<text x="225" y="155" text-anchor="middle" fill="#3498db" font-size="9">x₁</text>
<!-- Point on curve at x₁ -->
<circle cx="225" cy="146" r="3" fill="#3498db"/>
<line x1="225" y1="146" x2="225" y2="140" stroke="#3498db" stroke-width="0.8" stroke-dasharray="2"/>
<!-- Tangent from x₁ -->
<line x1="180" y1="140" x2="275" y2="125" stroke="#3498db" stroke-width="1.2" stroke-dasharray="4,3" opacity="0.7"/>
<!-- x₂ closer to root -->
<circle cx="195" cy="140" r="4" fill="#9b59b6"/>
<text x="195" y="170" text-anchor="middle" fill="#9b59b6" font-size="9">x₂</text>
<!-- Convergence arrow -->
<path d="M 305,175 Q 260,180 200,175" fill="none" stroke="#999" stroke-width="1" marker-end="url(#nm-arr)"/>
<text x="250" y="190" text-anchor="middle" fill="#999" font-size="9">converges to root</text>
</svg>