On Jul 4, 2012, at 3:46 PM, Goutam Paul wrote:

> Really need the contents.
> 
> Got an error message:
> "There was an error uploading the worksheet. It could be an old
> unsupported format or worse. If you desperately need its contents
> contact the sage-support group and post a link to your worksheet.
> Alternatively, an sws file is just a bzip2 tarball; take a look
> inside!"
> 
> bunzip2 didn't show readable output.

FWIW, I didn't have any problems running it through bunzip2 and tar.  I include 
below the contents of worksheet.txt.  You should be able to create a new 
worksheet, hit the "Edit" button, paste it in, "Save Changes", and then 
evaluate all of your cells.

HTH,
Ivan


eve
system:sage

{{{id=0|
d = var('d')
P0=plot(d,0,0.5,color='black',linestyle=":")
P1=plot(sqrt(d-d^2),0,0.5,color='blue',linestyle="-")
P2=plot(0.5*d+0.5*sqrt(2*d-3*(d^2)), 0, 0.5,color='red',linestyle="-")
P3=plot(8*(sqrt(d-d^2))^4,0,0.5,color='blue',linestyle="--")
P4=plot(0.5*(d+sqrt(2*d-3*(d^2)))^3,0,0.5,color='red',linestyle="--")
P5=plot(128*(sqrt(d-d^2))^8,0,0.5,color='blue',linestyle="-.")
P6=plot(0.5*(d+sqrt(2*d-3*(d^2)))^6,0,0.5,color='red',linestyle="-.")
P=P0+P1+P2+P3+P4+P5+P6
P.axes_labels(['$D$', 'Advantage($D$)'])
show(P)
///
}}}

{{{id=1|
import numpy as np
import matplotlib.pyplot as plt

fig = plt.figure(figsize=(12, 6), dpi=300)
ax = fig.add_subplot(1,1,1)

plt.clf()

def P0(x):
    return x    
 
def P1(x):
    return np.sqrt(x-x^2)

def P2(x):
    return 0.5*x+0.5*np.sqrt(2*x-3*(x^2))

def P3(x):
    return 4*(np.sqrt(x-x^2))^3

def P4(x):
    return 0.5*(x+np.sqrt(2*x-3*(x^2)))^2

def P5(x): 
    return (2^5)*(np.sqrt(x-x^2))^6

def P6(x):
    return 0.5*(x+np.sqrt(2*x-3*(x^2)))^4

def P7(x): 
    return (2^299)*(np.sqrt(x-x^2))^300

def P8(x):
    return 0.5*(x+np.sqrt(2*x-3*(x^2)))^200

d = np.arange(0.0,0.5,0.001)

plt.plot(d,P0(d),'g:',linewidth=2,label="$D$")
plt.plot(d,P1(d),'b-',label="$A^{4 state}_{opt}(D)$")
plt.plot(d,P2(d),'r-',label="$A^{6 state}_{opt}(D)$")
plt.plot(d,P3(d),'b--',linewidth=1.5,label="$A^{4 state}_{opt}(D, 3)$")
plt.plot(d,P4(d),'r--',linewidth=1.5,label="$A^{6 state}_{opt}(D, 2)$")
plt.plot(d,P5(d),'b-.',linewidth=1.5,label="$A^{4 state}_{opt}(D, 6)$")
plt.plot(d,P6(d),'r-.',linewidth=1.5,label="$A^{6 state}_{opt}(D, 4)$")
plt.plot(d,P7(d),color='cyan',linestyle="-",linewidth=1.5,label="$A^{4 
state}_{opt}(D, 300)$")
plt.plot(d,P8(d),color='magenta',linestyle="-",linewidth=1.5,label="$A^{6 
state}_{opt}(D, 200)$")
plt.axis([0,1,0,0.5])
plt.xticks([0,0.1,0.2,0.3,0.4,0.5])
plt.grid(True)
plt.legend(loc=7)
plt.xlabel('Disturbance $D$')
plt.ylabel('Optimal Advantage')
plt.savefig('adv.eps')
///
}}}

{{{id=2|
import numpy as np
import matplotlib.pyplot as plt

fig = plt.figure(figsize=(6, 6), dpi=300)
ax = fig.add_subplot(1,1,1)

plt.clf() 
 
def P1(x):
    return 0.5+np.sqrt(x-x^2)

def P2(x):
    return 0.5+0.5*x+0.5*np.sqrt(2*x-3*(x^2))

d = np.arange(0.0,0.5,0.001)

plt.plot(d,P1(d),'b--',linewidth=1.5)
plt.plot(d,P2(d),'r-.',linewidth=2)
plt.axis([0,0.5,0.5,1])
plt.grid(True)
plt.legend(['$P_{opt}^{4 state}(success)$','$P_{opt1}^{6 
state}(success)=P_{opt2}^{6 state}(success)$'],loc=4)
plt.xlabel('Disturbance $D$')
plt.ylabel('Optimal Success Probability')
plt.savefig('prob.eps')
///
}}}

{{{id=4|
import numpy as np
import matplotlib.pyplot as plt

fig = plt.figure(figsize=(6, 6), dpi=300)
ax = fig.add_subplot(1,1,1)

plt.clf() 

def Q0(x):
    return 1+x*np.log(x)/np.log(2)+(1-x)*np.log(1-x)/np.log(2)

def Q1(x):
    return 
1+(0.5+np.sqrt(x-x^2))*np.log(0.5+np.sqrt(x-x^2))/np.log(2)+(0.5-np.sqrt(x-x^2))*np.log(0.5-np.sqrt(x-x^2))/np.log(2)

def Q2(x):
    return 
1+(0.5+0.5*x+0.5*np.sqrt(2*x-3*(x^2)))*np.log(0.5+0.5*x+0.5*np.sqrt(2*x-3*(x^2)))/np.log(2)+(0.5-0.5*x-0.5*np.sqrt(2*x-3*(x^2)))*np.log(0.5-0.5*x-0.5*np.sqrt(2*x-3*(x^2)))/np.log(2)

def Q3(x):
    return 
1+(1-x)*((0.5+np.sqrt(2*x-3*(x^2))/(2-2*x))*np.log(0.5+np.sqrt(2*x-3*(x^2))/(2-2*x))/np.log(2)+(0.5-np.sqrt(2*x-3*(x^2))/(2-2*x))*np.log(0.5-np.sqrt(2*x-3*(x^2))/(2-2*x))/np.log(2))

d = np.arange(0.0,0.5,0.001)

plt.plot(d,Q0(d),'g-',linewidth=1.5)
plt.plot(d,Q1(d),'b--',linewidth=1.5)
plt.plot(d,Q2(d),'r-.',linewidth=2)
plt.plot(d,Q3(d),color='magenta',linestyle=':',linewidth=3)
plt.axis([0,0.5,0,1])
plt.grid(True)
plt.legend(['$I^{AB}$','$I^{AV}$','$I^{AV}_1$','$I^{AV}_2$'],loc=7)
plt.xlabel('Disturbance $D$')
plt.ylabel('Optimal Mutual Information')
plt.savefig('info.eps')
///
}}}

{{{id=5|
d = var('d')
P0=plot(sqrt(d-d^2),0,0.5,color='black',linestyle=":")
P1=plot((sqrt(0.5*d)/(0.5+d))*(1-d) + 
(sqrt(0.5*d))*d,0,0.5,color='blue',linestyle="-")
P2=plot(1-d,0,0.5,color='red',linestyle="--")
P=P0+P1+P2
P.axes_labels(['$D$', 'Advantage($D$)'])
show(P)
///
}}}

{{{id=8|

///
}}}

{{{id=6|
import numpy as np
import matplotlib.pyplot as plt

fig = plt.figure(figsize=(6, 6), dpi=300)
ax = fig.add_subplot(1,1,1)

plt.clf()

def P0(x):
    return x    
 
def P1(x):
    return np.sqrt(x-x^2)

def P2(x):
    return np.sqrt(0.5*x)/(0.5+x)

def P3(x):
    return ((np.sqrt(0.5*x)/(0.5+x))*0.5 + (np.sqrt(0.5*x))*0.5)

def P4(x):
    return (np.sqrt(0.5*x))*(5+2*x)/(4+4*x)

d = np.arange(0.0,0.5,0.001)

plt.plot(d,P0(d),'g-',linewidth=2,label="$D$")
plt.plot(d,P1(d),'b:',label="$A_E^{(1)}(D)$")
plt.plot(d,P2(d),color='magenta',linestyle='--',linewidth=2,label="$A_E^{(2,match)}(D)$")
plt.plot(d,P3(d),'r-.',label="$A_E^{(2,avg)}(D)$")
plt.plot(d,P4(d),'r-',label="$A_E^{(2,avg,H)}(D)$")
plt.axis([0,0.5,0,0.5])
plt.xticks([0,0.1,0.2,0.3,0.4,0.5])
plt.grid(True)
plt.legend(loc=4)
plt.xlabel('Disturbance $D$')
plt.ylabel('Advantage')
plt.savefig('adv1.eps')
///
}}}

{{{id=9|
import numpy as np
import matplotlib.pyplot as plt

fig = plt.figure(figsize=(6, 6), dpi=300)
ax = fig.add_subplot(1,1,1)

plt.clf()

def P0(x):
    return x    
 
def P1(x):
    return np.sqrt(x-x^2)

def P2(x):
    return np.sqrt(0.5*x)/(0.5+x)

def P3(x):
    return ((np.sqrt(0.5*x)/(0.5+x))*0.5 + (np.sqrt(0.5*x))*0.5)

def P4(x):
    return (np.sqrt(0.5*x))*(5+2*x)/(4+4*x)

d = np.arange(0.0,0.09,0.001)

plt.plot(d,P0(d),'g-',linewidth=2,label="$D$")
plt.plot(d,P1(d),'b:',linewidth=2, label="$A_E^{(1)}(D)$")
plt.plot(d,P2(d),color='magenta',linestyle='--',linewidth=2,label="$A_E^{(2,match)}(D)$")
plt.plot(d,P3(d),'r-.',linewidth=2,label="$A_E^{(2,avg)}(D)$")
plt.plot(d,P4(d),'r-',label="$A_E^{(2,avg,H)}(D)$")
plt.axis([0,0.09,0,0.3])
plt.xticks([0,0.01,0.02,0.03,0.04,0.05,0.06,0.07,0.08,0.09])
plt.grid(True)
plt.legend(loc=4)
plt.xlabel('Disturbance $D$')
plt.ylabel('Advantage')
plt.savefig('adv2.eps')
///
}}}

{{{id=7|
x = var('x')
solve([sqrt(x/2)*(3+2*x)/(2*(1+2*x)) - sqrt(x*(1-x))], x)
///
[x == (-2*sqrt(2)*sqrt(x - x^2) + 2*x^(3/2) + 3*sqrt(x))/(4*sqrt(2)*sqrt(x - 
x^2))]
}}}

{{{id=14|
def find_all_roots(f, a, b, eps=0.0000000001):
    roots = []
    intervals_to_check = [(a,b)]
    while intervals_to_check:
        start, end = intervals_to_check.pop()
        try:
            root = find_root(f, start, end)
        except RuntimeError:
            continue
        if root in roots:
            continue
        if abs(f(root)) < 1:
            roots.append(root)
        intervals_to_check.extend([(start, root-eps), (root+eps, end)])
    roots.sort()
    return roots
f = (sqrt(0.5*x)/(0.5+x))*0.5 + (sqrt(0.5*x))*0.5 - sqrt(x*(1-x))
g = (0.5-x) - ((sqrt(0.5*x)/(0.5+x))*0.5 + (sqrt(0.5*x))*0.5)
s1 = find_all_roots(f, 0, 0.5)
s2 = find_all_roots(g, 0, 0.5)
[s1,s2]
///
[[0.0, 0.087695264839551673, 0.5], [0.15131430678694469]]
}}}

{{{id=15|

///
}}}

-- 
To post to this group, send an email to [email protected]
To unsubscribe from this group, send an email to 
[email protected]
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to