ArrowedPlot

457 days ago by simonjtyler

Example plots for this ask.sagemath question:

f = x^3; xmin = -1; xmax = 1; small=.001; 
       
P = plot(f, (x, xmin, xmax),legend_label="$x^3$"); 
       
P + arrow((xmin, f(x=xmin)),(xmin-small,f(x=xmin-small)))\ + arrow((xmax, f(x=xmax)),(xmax+small,f(x=xmax+small))) 
       
f = cos(x^2); xmin = -1; xmax = 1; small=.001; P = plot(f, (x, xmin, xmax),legend_label="$cos(x^2)$"); P + arrow((xmin, f(x=xmin)),(xmin-small,f(x=xmin-small)))\ + arrow((xmax, f(x=xmax)),(xmax+small,f(x=xmax+small))) 
       
var("x y") f = x^2+y^3-2; xmin = -2; xmax = 2; small=.01; fd = f.derivative(x)/f.derivative(y); fd 
       
2/3*x/y^2
2/3*x/y^2
ymin = find_root(f(x=xmin),-2,2); ymax = find_root(f(x=xmax),-2,2); print ymin, ymax print fd(x=xmin,y=ymin), fd(x=xmax,y=ymax) 
       
-1.25992104989 -1.25992104989
-0.83994736659658209 0.83994736659658209
-1.25992104989 -1.25992104989
-0.83994736659658209 0.83994736659658209
P = implicit_plot(f, (x,xmin,xmax), (y,-2,2), legend_label="$x^2+y^3-2=0$") 
       
(P + arrow((xmin, ymin),(xmin-small,ymin+small*fd(x=xmin,y=ymin))) \ + arrow((xmax, ymax),(xmax+small,ymax-small*fd(x=xmax,y=ymax))) \ ).show(aspect_ratio=1)