Ask Your Question
1

Errors when plotting zeta function parametrically

asked 8 years ago

Wojowu gravatar image

updated 8 years ago

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.

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
4

answered 8 years ago

kcrisman gravatar image

updated 8 years ago

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().

Preview: (hide)
link

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 ( 8 years ago )

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 ( 8 years ago )
2

answered 8 years ago

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))
Preview: (hide)
link

Comments

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

Wojowu gravatar imageWojowu ( 8 years ago )

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

slelievre gravatar imageslelievre ( 8 years ago )

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: 8 years ago

Seen: 829 times

Last updated: Sep 21 '16