Francois Maltey wrote:
> I continue to try to plot in the complex plane the 4 solutions of the 
> equation :
> 
> z^4+2*a*z^2+1 = 0 when a is a real.
> 
> I want to get a circle and 2 lines...
> 
> Guru ckrisman explains that today this plot seems impossible and gives 
> me a tip with lambda : .... calls in plot.
> I can make more parametric_plot with but I can't get this one.
> 
> Guru harald proposes the use of list and list_plot... and I 
> misunderstand an other sage property :
> 
> var ("a,z")
> res = solve (z^4 + 2*a*z^2 + 1 == 0,  z)   # is right
> res1 = res[0].rhs() # - sqrt (-a+sqrt(a^2-1)), others have + or -...
> res2 = - sqrt (-a+sqrt(a^2-1)) # I type the same expression
> 
> [res2 for a in sxrange (-5,5,0.8)] # is right
> [res1 for a in sxrange (-5,5,0.8)] # makes an error, even if the display 
> of the inner formula is the same.


To substitute values into a symbolic expression, use either the .subs 
function or just call the expression like it is a function, but 
explicitly specify the values of the variables:

[res1.subs(a=i) for i in sxrange(-5,5,0.8)]

[res1(a=i) for i in sxrange(-5,5,0.8)]

> 
> # I try this other case :
> 
> b=a
> [sqrt(a) for a in sxrange(-2,2,0.8)] # is right
> [sqrt(b) for a in sxrange(-2,2,0.8)] # repeat the last value.
> # It seems that a remains a numerical variable outside the for loop.


These last two statements are assigning the python variable "a" to the 
values -2, -1.2, ..., 2.  When you finish the statement, "a" still 
points to the last numeric value.

Think of it this way: when you do var('a'), an object, a symbolic 
variable, is created.  The python variable "a" is set to this symbolic 
variable.  However, they are two separate things.  In a sense, you can 
think of it as the name "a" is pointing to this symbolic variable, which 
Sage prints as "a".

a --> (Sage symbolic variable, which is printed as "a")

When you do the above statements, you are reassigning what "a" points 
to.  After the above statements, you have:

a --> 2

but there is still a symbolic variable out there called "a"; it just 
isn't accessed by typing "a" anymore.

I hope that helps.

Jason



-- 
Jason Grout


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

Reply via email to