Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Valid Python identifier

For some days, I struggle with unicode. I haved followed the answer of my question "An error using unicode?" wich is to define

\pi(+TAB) = var('pi')
 x = var('x')

or (I suppose) \pi(+TAB), x = var('pi x') x = var('x')

but later, in my code I use \pi + Tab and I receive an error code The name "ϕ" is not a valid Python identifier (here it is "ϕ", because I have replaced pi by phi under the reasoning that pi was certainly a keyword in some packages). Is it one more time a problem of understanding ?

Valid Python identifier

For some days, I struggle with unicode. I haved followed the answer of my question "An error using unicode?" wich is to define

\pi(+TAB) = var('pi')
 x = var('x')

or (I suppose) (0I suppose)

\pi(+TAB), x = var('pi x')
  x = var('x')

var('x')

but later, in my code I use \pi + Tab and I receive an error code The name "ϕ" is not a valid Python identifier (here it is "ϕ", because I have replaced pi by phi under the reasoning that pi was certainly a keyword in some packages). Is it one more time a problem of understanding ?

I have also tried

\pi(+TAB) = var('pii')
 x = var('x')

to try to by pass the difficulty.

Valid Python identifier

For some days, I struggle with unicode. I haved followed the answer of my question "An error using unicode?" wich is to define

\pi(+TAB) = var('pi')
 x = var('x')

or (0I suppose)

\pi(+TAB), x = var('pi x')
 x = var('x')

but later, in my code I use \pi + Tab and I receive an error code The name "ϕ" is not a valid Python identifier (here it is "ϕ", because I have replaced pi by phi under the reasoning that pi was certainly a keyword in some packages). Is it one more time a problem of understanding ?

I have also tried

\pi(+TAB) = var('pii')
 x = var('x')

to try to by pass the difficulty.

Here is my code. It comes in some cells so I kept them.

%%html
<style>
body {
    font-family: "Palatino Linotype", cursive, sans-serif;
     background-color: rgb(252,251,251);
}
.prompt {
    font-family: "Palatino Linotype", cursive, sans-serif;
    font-size: 15px;
    min-width: 6em;
}
.input-prompt {
    color: rgb(108, 119, 188);
}
.output-prompt {
    color: rgb(20, 129, 106);
}
code, kbd, pre, samp, .CodeMirror {
    font-family:  "Palatino Linotype", cursive, sans-serif;
    font-size: 15px;
}

</style>

p, D, w_0, x, I = var('p, D, w_0, x, I')
β = var('beta')
ϕ = var('phi') 
w00=8
D1=6

% display latex

pl=line([(0,0), (10,10)], color="cyan",ticks=[[], []])
pl+=text("$W_2$",(-.5,10),color="black", fontsize='small')
pl+=text("$W_1$",(10,-.5),color="black", fontsize='small')
pl+=text("$Ligne$ $de$\n  $certitude$",(9,9),color="red", fontsize='small', rotation=45)
pl1=circle((w00,w00-D1), .075, fill=True, edgecolor='red', facecolor='red')
pl1+=line([(w00,0), (w00,w00-D1), (0,w00-D1)], linestyle="--")
pl1+=text("$W_0-D$",(-.75, w00-D1),color="black", fontsize='small')
pl1+=text("$W_0$",(w00,-.5),color="black", fontsize='small')
pl1+=text("$W_0$",(-.5, w00),color="black", fontsize='small')
pl1+=line([(w00,w00-D1), (w00,w00),(0,w00)], linestyle="--")
pl1+=circle((w00,w00), .075, fill=True, edgecolor='red', facecolor='red')
pl2=polygon([(0,0), (0,10), (10,10), (0,0)], fill=True, rgbcolor=(0.95,0.95,0.95),ticks=[[], []]) 
pl2+=text("$Loteries$ $inaccesibles$\n $par$ $inversion$ $d'états$",(4.5,9.1),color="red", fontsize='small', 
         background_color="white")
pl2+=polygon([(w00,0), (w00,w00), (10,10), (10,0)], fill=True, rgbcolor=(0.70,0.95,0.95),ticks=[[], []]) 
pl2+=text("$Loteries$ $inaccesibles$ $par$\n  $insuffisance$ $de$ $ressources$",(9.,5),color="red", 
         fontsize='small',background_color="white", rotation=90)
pl2+=polygon([(0,0), (w00-D1,w00-D1), (w00,w00-D1), (w00,0)], fill=True, rgbcolor=(0.95,0.75,0.95),ticks=[[], []]) 
pl2+=text("$Loteries$ $indésirable$ $par$\n $dégradation$ $des$ $deux$ $états$",(4.8,1),color="red", 
         fontsize='small', background_color="white", rotation=0)
pl12=pl+pl1+pl2
show(pl12)

And now comes the error

A = matrix(SR, 2, 2, [[w_0, 1],[w_0-ϕ,1]])
y = vector([w_0-D, w_0-D-ϕ+I])
sol=A.solve_right(y)
sola=sol[0].full_simplify().function(D, ϕ, w_0)
solb=sol[1].full_simplify().function(D, ϕ, I, w_0)
f(x, D, ϕ, I, w_0)=sola*x + solb

Here it is $\phi$ but I have the same problem with other characters.