ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 15 Nov 2016 08:24:22 -0600Using max and plothttp://ask.sagemath.org/question/35576/using-max-and-plot/ I want to plot a function such as
x mapsto max(x,1).
How do I do that?
Mon, 14 Nov 2016 14:18:59 -0600http://ask.sagemath.org/question/35576/using-max-and-plot/Answer by kcrisman for <p>I want to plot a function such as
x mapsto max(x,1).
How do I do that?</p>
http://ask.sagemath.org/question/35576/using-max-and-plot/?answer=35577#post-id-35577[Try this](http://sagecell.sagemath.org/?z=eJwryMkv0chNrIgvrsxNys_JTNao0DHU1AGSuqY6ppo6lbmZebYGmgATJAx4&lang=sage) using `max_symbolic`. It won't do as much as you might like, but you can plot it, at least.
Edit - didn't have time to include the code earlier:
plot(max_symbolic(x,1),(x,-5,5),ymin=0)Mon, 14 Nov 2016 14:26:21 -0600http://ask.sagemath.org/question/35576/using-max-and-plot/?answer=35577#post-id-35577Comment by oldnovice for <p><a href="http://sagecell.sagemath.org/?z=eJwryMkv0chNrIgvrsxNys_JTNao0DHU1AGSuqY6ppo6lbmZebYGmgATJAx4&lang=sage">Try this</a> using <code>max_symbolic</code>. It won't do as much as you might like, but you can plot it, at least.</p>
<p>Edit - didn't have time to include the code earlier:</p>
<pre><code>plot(max_symbolic(x,1),(x,-5,5),ymin=0)
</code></pre>
http://ask.sagemath.org/question/35576/using-max-and-plot/?comment=35592#post-id-35592Thank you very much for your help. This does what I want.Tue, 15 Nov 2016 08:23:48 -0600http://ask.sagemath.org/question/35576/using-max-and-plot/?comment=35592#post-id-35592Answer by slelievre for <p>I want to plot a function such as
x mapsto max(x,1).
How do I do that?</p>
http://ask.sagemath.org/question/35576/using-max-and-plot/?answer=35591#post-id-35591Try using a lambda function.
This works for me:
sage: plot(lambda x: max(x, 1), (-5, 5), ymin=0)
Tue, 15 Nov 2016 08:07:39 -0600http://ask.sagemath.org/question/35576/using-max-and-plot/?answer=35591#post-id-35591Comment by oldnovice for <p>Try using a lambda function.</p>
<p>This works for me:</p>
<pre><code>sage: plot(lambda x: max(x, 1), (-5, 5), ymin=0)
</code></pre>
http://ask.sagemath.org/question/35576/using-max-and-plot/?comment=35593#post-id-35593Thank you, too. I really appreciate your help. This also does what I want.Tue, 15 Nov 2016 08:24:22 -0600http://ask.sagemath.org/question/35576/using-max-and-plot/?comment=35593#post-id-35593