Closed jasongrout closed 15 years ago
This is a duplicate of #1877. I think it should be possible to use a variable mutliple times in the range, i.e. x,x
or also x,-x
. Since this description is far from precise, i.e. one would never find it looking for the issue, I am closing this.
Jason: feel free to reopen if you disagree.
Cheers,
Michael
To my understanding, the issue in #1877 was the specifying of the same variable in two different ranges. This issue is different: when I use "-u", I get an error, but when I use an expression that is equivalent to "-u", I don't get an error. In either case, I'm not specifying two of the same variable for the ranges.
I think these issues are different. They may be symptoms of the same thing, but I doubt it.
Changing the issue title to be more descriptive.
To elaborate on the reopening: the issue here is not with the ranges (to my knowledge, it isn't even possible to specify variables for the ranges in parametric_plot3d). The issue here is with the components of the function being plotted.
Ok, agreed that this is a different bug than #1877:
sage: var('u v t')
(u, v, t)
sage: parametric_plot3d((u,-v,t), (-10,10),(-10,10))
---------------------------------------------------------------------------
<type 'exceptions.ValueError'> Traceback (most recent call last)
/scratch/mabshoff/release-cycle/sage-3.0.alpha3/<ipython console> in <module>()
/scratch/mabshoff/release-cycle/sage-3.0.alpha3/local/lib/python2.5/site-packages/sage/plot/plot3d/parametric_plot3d.py in parametric_plot3d(f, urange, vrange, plot_points, **kwds)
360 if plot_points == "automatic":
361 plot_points = [40,40]
--> 362 G = parametric_plot3d_surface(f, urange, vrange, plot_points, **kwds)
363 G._set_extra_kwds(kwds)
364 return G
/scratch/mabshoff/release-cycle/sage-3.0.alpha3/local/lib/python2.5/site-packages/sage/plot/plot3d/parametric_plot3d.py in parametric_plot3d_surface(f, urange, vrange, plot_points, **kwds)
421
422 try:
--> 423 g, (u,v) = adapt_to_callable(f, 2)
424 except TypeError:
425 g = tuple(f)
/scratch/mabshoff/release-cycle/sage-3.0.alpha3/local/lib/python2.5/site-packages/sage/plot/plot3d/parametric_plot3d.py in adapt_to_callable(f, nargs)
488
489 if nargs is not None and len(vars) != nargs:
490 vars = (vars + ('_',)*nargs)[:nargs]
491
--> 492 return fast_float(f, *vars), vars
/scratch/mabshoff/release-cycle/sage-3.0.alpha3/fast_eval.pyx in sage.ext.fast_eval.fast_float()
/scratch/mabshoff/release-cycle/sage-3.0.alpha3/fast_eval.pyx in sage.ext.fast_eval.fast_float()
/scratch/mabshoff/release-cycle/sage-3.0.alpha3/local/lib/python2.5/site-packages/sage/calculus/calculus.py in _fast_float_(self, *vars)
4598 1.0
4599 """
-> 4600 fops = [op._fast_float_(*vars) for op in self._operands]
4601 return self._operator(*fops)
4602
/scratch/mabshoff/release-cycle/sage-3.0.alpha3/local/lib/python2.5/site-packages/sage/calculus/calculus.py in _fast_float_(self, *vars)
5112 return fast_float.fast_float_constant(float(self))
5113 except TypeError:
-> 5114 raise ValueError, "free variable: %s" % self._name
5115
5116 def _recursive_sub(self, kwds):
<type 'exceptions.ValueError'>: free variable: v
sage:
Using u twice in the range might have obscured the real bug from my POV. Mea culpa.
+1 on the better description.
Cheers,
Michael
The problem seems to be in parametric_plot3d.py in adapt_to_callable, in the line "s=sum(f)". If there is a u and a -u as components of f, then sum(f) cancels these and the variable disappears.
Attachment: trac_2858.patch.gz
mike found one bug which this fixes.
Attachment: trac_2858-part2.patch.gz
Looks good to me.
Merged both patches in Sage 3.3.alpha3
The following two plots should give the same thing.
Component: graphics
Issue created by migration from https://trac.sagemath.org/ticket/2858