Ask Your Question

uglychamaeleon's profile - activity

2020-03-12 05:13:09 +0100 received badge  Popular Question (source)
2020-03-12 05:13:09 +0100 received badge  Notable Question (source)
2019-07-12 06:57:32 +0100 received badge  Popular Question (source)
2015-03-14 21:56:46 +0100 received badge  Scholar (source)
2015-03-14 21:56:42 +0100 commented answer Recurrent definiton of a function

Great, adding

def H11(r1):
    r1 = ZZ(r1)
    ....

resolved the problem. Thanks a lot!

2015-03-14 21:47:20 +0100 received badge  Student (source)
2015-03-14 21:37:35 +0100 commented question Recurrent definiton of a function

@vdelecroix, Thanks, I should have stated the problem more explicitly. I've added the setup to the question.

2015-03-14 20:45:32 +0100 asked a question Recurrent definiton of a function

Hi, I am trying to compose a code for calculating the numbers H01 defined as a sum of the following recursively defined numbers:

H11(r) = \sum_{a + b = r}  a*b/r  (H11(a) + H12(a)) * H11(b)
H12(r) = \sum_{a + b = r}  a*b/r  (H11(a) + H12(a)) * (H11(b) + H12(b))

H01(r) = H11(r) + H12(r)

I ended up with the following code:

memoH11 = {1:0, 2:1/2}
def H11(r1):  
    if memoH11.has_key(r1):
        return memoH11[r1]
    else:
        a = 0
        for j1 in range(1,r1):
            a += j1*(r1 - j1)/r1 * (H11(j1) + H12(j1)) * H11(r1-j1)
        memoH11[r1] = a
        return a 


memoH12 = {1:0, 2:0}
def H12(r2):  
    if memoH12.has_key(r2):
        return memoH12[r2]
    else:
        b = 0
        for j2 in range(1,r2):
            b += j2*(r2 - j2)/r2 * ( H11(j2) + H12(j2) ) * ( H11(r2 - j2) + H12(r2-j2) )
        memoH12[r2] = b
        return b 

def H01(r):    
    return H11(r) + H12(r)

And here problems start. If I just type

H01(8)

it produces the incorrect value 27/8. But if I type

H01(6), H01(8)

it results the correct tuple (7/6, 15/4).

So how to fix the code ? Thanks in advance for any help.

2014-11-17 00:36:39 +0100 commented question plotting a plane section in sage

@tmonteil Sorry for misleading notation. X, y and z are functions in two variables p and q.

2014-11-14 22:16:41 +0100 received badge  Editor (source)
2014-11-14 21:55:50 +0100 asked a question plotting a plane section in sage

Suppose I have a parametric surface given by three functions in two variables. Moreover, this surface is immersed in a solid torus like

sage: p1 = parametric_plot(( a*(R + x)*cos(z), a*(R + y)*sin(z), a*y ),(p,0,2*pi),(q,0,2*pi))

for some a and R.

How can one plot a section of the surface by a plane with Sage?