Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

contour_plot/plot and function arguments

Hello,

I am considering switching from Mathematica to Sage but I am confused on some fundamental matters pertaining Sage. I really appreciate if you could shed some light on the problem .

Let's look at the code in Sage:

reset()
f(k1,k2) = k1^2 + k2
contour_plot(f,(0,2),(3,5))

this code beautifully draws the contour. Now, what I tried was switching the order of the arguments of f from f(k1,k2) to f(k2,k1):

f(k2,k1)=k1^2+k2

What I intuitively expected was the switch of the graph. I expected (0,2) to match k2 instead of k1 since it is the first argument of the new function f and (3,5) to k1 instead of k2 (for the same reasoning). However, the graph was identical to that of f(k1,k2). How does Sage choose range arguments to match with f arguments?

I have a similar problem with plot as well:

t=var('t')
f(z)=z^2
plot(f(z),(t,0,5))

This code draws the graph, but the function is in z and the range variable is in t. Shouldn't it give an error?! This code is wrong in Mathematica

f[z_]=z^2
Plot[f[z],{t,0,5}]

it should be Plot[f[t],{t,0,5}]. Why doesn't Sage give an error?