Processing math: 100%
Ask Your Question
2

How to plot a complicated function in Sage Math

asked 7 years ago

Fragmenter gravatar image

I apologize in advance for my lack of knowledge and understanding of sage. In principle what I want to achieve is the visualization of this function:

g|xx12| f(x):=j=02jg(2jx)

Though I am having trouble finding out how to do this. In the documentation I did not find any easy way to handle infinite series.

I am sure this would be very helpful to many that struggle with a math problem and need to see it to believe it. A conventional plotting program will not work here, hence I searched for a better tool and found Sage Math. Is it possible in sage? Do you have any TLDR material that I could look into?

Thank you for your help.

Preview: (hide)

Comments

So do you want to plot a function which is 1 for x>=0 and +Infinity for x<0?

roberto gravatar imageroberto ( 7 years ago )

My bad I thought it was abs(x) instead of floor(x)

roberto gravatar imageroberto ( 7 years ago )

1 Answer

Sort by » oldest newest most voted
4

answered 7 years ago

B r u n o gravatar image

You can proceed as follows, where N is given to serve as an approximation of .

sage: g(x) = abs(x - floor(x) - 1/2)
sage: def f(x, N): return sum(g(2^j*x)/2^j for j in range(N+1))
sage: N = 100 # for instance...
sage: plot(f(x, N), x, -1, 1)

Resulting plot

Note. For this approach to make sense, you need to show that that the partial sums converge fast, which is the case since g(x)1/2 for all x.

Preview: (hide)
link

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 7 years ago

Seen: 771 times

Last updated: Jul 03 '17