Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

Numerical Methods Homework

Views: 706
Kernel: SageMath 8.2
def bezier(x1,y1,x2,y2,x3,y3,x4,y4): import numpy as np bx = 3*(x2-x1) cx = 3* (x3-x2)-bx dx = x4-x1-bx-cx by = 3*(y2-y1) cy = 3* (y3-y2)-by dy = y4-y1-by-cy def x(t): return x1+bx*t+cx*t^2+dx*t^3 def y (t): return y1+bx*t+cx*t^2+dx*t^3 t = np.linspace(-1.5,1.5,100) plot(x(t),y(t)) bezier(-1,0,1,0,0,1,0,1)
/ext/sage/sage-8.2/local/lib/python2.7/site-packages/sage/plot/plot.py:2069: DeprecationWarning: elementwise == comparison failed; this will raise an error in the future. if funcs == []:
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-1-770a5f970e15> in <module>() 13 t = np.linspace(-RealNumber('1.5'),RealNumber('1.5'),Integer(100)) 14 plot(x(t),y(t)) ---> 15 bezier(-Integer(1),Integer(0),Integer(1),Integer(0),Integer(0),Integer(1),Integer(0),Integer(1)) <ipython-input-1-770a5f970e15> in bezier(x1, y1, x2, y2, x3, y3, x4, y4) 12 return y1+bx*t+cx*t**Integer(2)+dx*t**Integer(3) 13 t = np.linspace(-RealNumber('1.5'),RealNumber('1.5'),Integer(100)) ---> 14 plot(x(t),y(t)) 15 bezier(-Integer(1),Integer(0),Integer(1),Integer(0),Integer(0),Integer(1),Integer(0),Integer(1)) /ext/sage/sage-8.2/local/lib/python2.7/site-packages/sage/misc/decorators.pyc in wrapper(*args, **kwds) 562 options['__original_opts'] = kwds 563 options.update(kwds) --> 564 return func(*args, **options) 565 566 #Add the options specified by @options to the signature of the wrapped /ext/sage/sage-8.2/local/lib/python2.7/site-packages/sage/plot/plot.pyc in plot(funcs, *args, **kwds) 1954 # if there is one extra arg, then it had better be a tuple 1955 elif n == 1: -> 1956 G = _plot(funcs, *args, **kwds) 1957 elif n == 2: 1958 # if there are two extra args, then pull them out and pass them as a tuple /ext/sage/sage-8.2/local/lib/python2.7/site-packages/sage/plot/plot.pyc in _plot(funcs, xrange, parametric, polar, fill, label, randomize, **options) 2072 excluded_points = [] 2073 funcs, ranges = setup_for_eval_on_grid(funcs, [xrange], options['plot_points']) -> 2074 xmin, xmax, delta = ranges[0] 2075 xrange=ranges[0][:2] 2076 # parametric_plot will be a list or tuple of two functions (f,g) ValueError: too many values to unpack