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.Wed, 14 Aug 2013 23:39:11 +0200Question about error using plothttps://ask.sagemath.org/question/10435/question-about-error-using-plot/Hello all,
I'd like to view the plot of the real portion of `(1+x*I)^(1+5*I)`. I've tried the following in sage:
`plot(((.5+x*I)^(1+5*I)).real(),(x,0,5))` but I keep getting cannot convert symbolic expression to numeric value.
Honestly, I'd actually like to integrate the expression with respect to x on some arbitrary real interval. That kept giving errors as well when I tried to use integral_numerical.
Can anyone help me? I am running the newest edition of sage, as I updated two days ago.
Thanks,
RickWed, 14 Aug 2013 21:02:51 +0200https://ask.sagemath.org/question/10435/question-about-error-using-plot/Answer by kcrisman for <p>Hello all,</p>
<p>I'd like to view the plot of the real portion of <code>(1+x*I)^(1+5*I)</code>. I've tried the following in sage:</p>
<p><code>plot(((.5+x*I)^(1+5*I)).real(),(x,0,5))</code> but I keep getting cannot convert symbolic expression to numeric value.</p>
<p>Honestly, I'd actually like to integrate the expression with respect to x on some arbitrary real interval. That kept giving errors as well when I tried to use integral_numerical. </p>
<p>Can anyone help me? I am running the newest edition of sage, as I updated two days ago.</p>
<p>Thanks,</p>
<p>Rick</p>
https://ask.sagemath.org/question/10435/question-about-error-using-plot/?answer=15347#post-id-15347It's possible that [Trac 13355](http://trac.sagemath.org/ticket/13355) may end up solving this problem as well.Wed, 14 Aug 2013 23:39:11 +0200https://ask.sagemath.org/question/10435/question-about-error-using-plot/?answer=15347#post-id-15347Answer by tmonteil for <p>Hello all,</p>
<p>I'd like to view the plot of the real portion of <code>(1+x*I)^(1+5*I)</code>. I've tried the following in sage:</p>
<p><code>plot(((.5+x*I)^(1+5*I)).real(),(x,0,5))</code> but I keep getting cannot convert symbolic expression to numeric value.</p>
<p>Honestly, I'd actually like to integrate the expression with respect to x on some arbitrary real interval. That kept giving errors as well when I tried to use integral_numerical. </p>
<p>Can anyone help me? I am running the newest edition of sage, as I updated two days ago.</p>
<p>Thanks,</p>
<p>Rick</p>
https://ask.sagemath.org/question/10435/question-about-error-using-plot/?answer=15345#post-id-15345You can define your function first, and then plot it:
sage: f(x) = ((1+x*I)^(1+5*I)).real()
sage: plot(f,x,0,5)
But concerning your second question,
sage: integral_numerical(f,0,1)
leads to an error. A workaround is to define your function `f` not as a symbolic expression, but as a lambda function:
sage: f = lambda x: ((1+x*I)^(1+5*I)).real()
sage: plot(f,x,0,5)
sage: integral_numerical(f,0,1)
(0.1786803251930374, 2.0932402003702034e-15)
Wed, 14 Aug 2013 22:35:36 +0200https://ask.sagemath.org/question/10435/question-about-error-using-plot/?answer=15345#post-id-15345