ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 15 Nov 2016 15:24:22 +0100Using max and plothttps://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 21:18:59 +0100https://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>
https://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 21:26:21 +0100https://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>
https://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 15:23:48 +0100https://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>
https://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 15:07:39 +0100https://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>
https://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 15:24:22 +0100https://ask.sagemath.org/question/35576/using-max-and-plot/?comment=35593#post-id-35593