Ask Your Question
1

Errors when plotting zeta function parametrically

asked 2016-09-21 16:46:11 +0100

Wojowu gravatar image

updated 2016-09-21 17:45:33 +0100

I have the following piece of code:

def f(x):
    return(real_part(zeta(1+x*I)).n())
def g(x):
    return(imag_part(zeta(1+x*I)).n())
parametric_plot([f(x),g(x)], (x,2,10))

It should be moderately clear what I'm trying to do - I want to produce a plot of Riemann zeta function on the line Re(z)=1 using parametric plotting. However, when I try to plot this, I get an error TypeError: cannot evaluate symbolic expression numerically. I also tried the same thing without the .n(), but then I get an error TypeError: unable to coerce to a real number. I couldn't find any help online.

It's worth noting that trying to plot function f(x) I get the same error with .n(), but it works just fine without it (as opposed to parametric plot). Does anyone have an idea how to fix the issue?

Thanks in advance.

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
4

answered 2016-09-21 18:50:20 +0100

kcrisman gravatar image

updated 2016-09-21 18:51:20 +0100

You mean something like this?

image description

In doing a lot of things like this in this project I had to use things lambda t: zeta(sig+t*i).real() because the symbolic version wouldn't handle it, I guess. So lambda functions and .real().

edit flag offensive delete link more

Comments

1

Thank you very much! I am relatively new to both Python and Sage, so any help is appreciated. By the way (although this isn't strictly relate to my overall question), do you know of a way to make the the plot non-monochromatic? I am thinking of making the hue of the line changing as x increases, so that the plot looks rainbow-y.

Wojowu gravatar imageWojowu ( 2016-09-21 23:04:54 +0100 )edit

Hmm, it's certainly possible (see here)but I don't think we've "wrapped" that matplotlib functionality. See https://trac.sagemath.org/ticket/21564

kcrisman gravatar imagekcrisman ( 2016-09-22 19:21:58 +0100 )edit
2

answered 2016-09-21 18:48:02 +0100

FrédéricC gravatar image

try like this:

f=lambda x: zeta(1+x*I).real_part()
g=lambda x: zeta(1+x*I).imag_part()
parametric_plot([f,g], (x,2,10))
edit flag offensive delete link more

Comments

Thank you very much! I am relatively new to both Python and Sage, so any help is appreciated.

Wojowu gravatar imageWojowu ( 2016-09-21 23:05:06 +0100 )edit

@Wojowu - you can upvote the answer if you find it useful!

slelievre gravatar imageslelievre ( 2016-11-05 15:31:50 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2016-09-21 16:46:11 +0100

Seen: 742 times

Last updated: Sep 21 '16