Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The following worked for me:

# example:
f(x) = 2*sin(2*x + 4)
g(x) = 3*sin(-x - 4)

eq = f - g
pf = plot(f(x), (x, -pi, pi)
          , color="red"
          , fill=max_symbolic(f(x),g(x))
          , fillcolor="lightgreen")
pg = plot(g(x), (x, -pi, pi)
          , color="blue")
# show(pf + pg)

nbi = 20
endpoints = [-pi + 2*pi*k/(nbi - 1) for k in range(nbi)]
c = []

for i in range(nbi-1):
    try:
        a = endpoints[i]
        b = endpoints[i + 1]
        sol = eq.find_root(a, b)
        c.append(n(sol, digits=3))
    except RuntimeError:
        rep = "no sol" #sometime I need to treat that properly

yc = [f(k) for k in c]
mes_points = point([ (p, f(p)) for p in c], marker='o', color='maroon', size=60)
print(mes_points)
ph = plot(mes_points)

show(pf + pg + ph)

Your points have to be constructed such that a graphics object results from this.

sage: type(mes_points)
<class 'sage.plot.graphics.Graphics'>

It should also work:

show(pf + pg + mes_points)

Also take a look at sage point doc, the section with

sage.plot.point.point2d(points, alpha=1, aspect_ratio='automatic', faceted=False, legend_color=None, legend_label=None, marker='o', markeredgecolor=None, rgbcolor=(0, 0, 1), size=10, **options)