Ask Your Question

An error using unicode?

asked 2020-05-12 12:42:33 +0200

Cyrille gravatar image

Following the short answer of "Automatic substitution of unicode characters", the following code works nicely

%display unicode_art
π = var('pi')
solu=solve(π^2 - π==0, π)   

But if this code works nicely too

var("w0, pi, D, I")
A = matrix(SR, 2, 2, [[w0, 1],[w0-pi,1]])
y = vector([w0-D, w0-D-pi+I])
%display unicode_art
sola=sol[0].full_simplify().function(D, pi, I, w0)
solb=sol[1].full_simplify().function(D, pi, I, w0)
f(x, D, π, I, w0)=sola*x + solb
f(x, D, π, I, w0)

The use of unicode on the preceding code generates an error

%display unicode_art
π = var('pi')
var("w0, π, D, I")
A = matrix(SR, 2, 2, [[w0, 1],[w0-π,1]])
y = vector([w0-D, w0-D-π+I])
sola=sol[0].full_simplify().function(D, π, I, w0)
solb=sol[1].full_simplify().function(D, π, I, w0)
f(x, D, π, I, w0)=sola*x + solb
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2020-05-12 15:22:40 +0200

tmonteil gravatar image

When you write var("w0, π, D, I") you overwrite the Python name π to point to te symbol SR.var('π') (that some libraries can not handle), while it should point to the symbol SR.var('pi').

Hence, to fix your issue, you have to replace

var("w0, π, D, I")


var("w0, D, I")
edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

1 follower


Asked: 2020-05-12 12:42:33 +0200

Seen: 197 times

Last updated: May 12 '20