#11258: Add documentation for plotting max and min functions
-------------------------------+--------------------------
Reporter: kcrisman | Owner: jason, was
Type: enhancement | Status: new
Priority: major | Milestone:
Component: graphics | Resolution:
Keywords: beginner | Merged in:
Authors: | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
Dependencies: | Stopgaps:
-------------------------------+--------------------------
Old description:
> To do this, you need `min_symbolic` and `max_symbolic`, as in #6949. But
> I don't think this is in the documentation for plotting anywhere.
>
> {{{
> M = matrix([[1,-1],[-1,1]])
> f1(p) = (M[1,0] - M[0,0])*p+M[0,0]
> f2(p) = (M[1,1] - M[0,1])*p+M[0,1]
> P = plot([f1,f2],(p,0,1),linestyle='--')
> P += plot(min_symbolic(f1(p),f2(p)),(p,0,1),color='red')
> show(P,axes_labels=['$p$','Exp.'])
> }}}
> Notice that
> {{{
> P += plot(min_symbolic(f1,f2),(p,0,1),color='red')
> }}}
> and
> {{{
> P += plot(min(f1(p),f2(p)),(p,0,1),color='red')
> }}}
> don't work properly. I could even consider the first one a bug...
>
> Putting in component 'graphics' because it's more likely these people
> will write documentation for this than symbolics or doc people!
New description:
The function `min` and `max` are Python builtins. The name of the
corresponding symbolic functions are `min_symbolic` and `max_symbolic that
were implemented in #6949:
{{{
sage: f(x) = min_symbolic(cos(x), sin(x))
sage: f
x |--> min(cos(x), sin(x))
}}}
It would be nice to have examples involving them in the function
`sage.plot.plot.plot`. Those can be
{{{
sage: f(x) = min_symbolic(cos(x), sin(x))
sage: f
x |--> min(cos(x), sin(x))
sage: plot(f, (x,-2*pi,2*pi))
}}}
or/and
{{{
sage: f1(p) = 2*p + 1
sage: f2(p) = -p + 3
sage: f3(p) = 4*p - 1
sage: f4(p) = 3/2*p
sage: P = plot([f1,f2,f3,f4], (p,0,2), linestyle='--')
sage: P += plot(max_symbolic(f1(p), f2(p), f3(p), f4(p)), (p,0,2),
color='red')
sage: P += plot(min_symbolic(f1(p), f2(p), f3(p), f4(p)), (p,0,2),
color='green')
sage: P.show()
}}}
But be careful that the following currently does not work
{{{
sage: symbolic_min(f1, f2)
Traceback (most recent call last):
...
TypeError: ...
}}}
--
Comment (by vdelecroix):
Hi there,
I rewrote a bit the description (please check that you agree). Involving
the matrix in the example was quite confusing. I might use it for an
introduction to Sage development on june 25th 2014.
Vincent
--
Ticket URL: <http://trac.sagemath.org/ticket/11258#comment:4>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.