ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 16 Apr 2018 10:49:14 -0500Correct input for list_plot3d(..., interpolation='spline')http://ask.sagemath.org/question/42020/correct-input-for-list_plot3d-interpolationspline/I'm trying to construct smooth surfaces from lists of points in 3-space using `list_plot3d` and the `spline` option, but without success. For example, the input
> list_plot3d ([(-1, 2, 3), (2, -1, 3), (3, -1, 2), (-1 ,3 ,2), (2, 3, -1), (3, 2, -1)], interpolation_type='spline')
returns the error
>TypeError: m >= (kx+1)(ky+1) must hold
The following returns the expected piecewise linear surface suggesting that there is a special restriction on the input when using the `spline` option.
> list_plot3d ([(-1, 2, 3), (2, -1, 3), (3, -1, 2), (-1 ,3 ,2), (2, 3, -1), (3, 2, -1)])
**Question**: What is the correct input to obtain a best fit polynomial surface going through the six points in $\mathbb{R}^3$?
**Edit**: As pointed out by @slelievre, since these six points lie in a common plane, the corresponding surface should be the plane containing the points. So why does `Sage` throw an error instead of this plane?Sun, 15 Apr 2018 13:05:24 -0500http://ask.sagemath.org/question/42020/correct-input-for-list_plot3d-interpolationspline/Comment by amdall for <p>I'm trying to construct smooth surfaces from lists of points in 3-space using <code>list_plot3d</code> and the <code>spline</code> option, but without success. For example, the input</p>
<blockquote>
<p>list_plot3d ([(-1, 2, 3), (2, -1, 3), (3, -1, 2), (-1 ,3 ,2), (2, 3, -1), (3, 2, -1)], interpolation_type='spline')</p>
</blockquote>
<p>returns the error </p>
<blockquote>
<p>TypeError: m >= (kx+1)(ky+1) must hold</p>
</blockquote>
<p>The following returns the expected piecewise linear surface suggesting that there is a special restriction on the input when using the <code>spline</code> option.</p>
<blockquote>
<p>list_plot3d ([(-1, 2, 3), (2, -1, 3), (3, -1, 2), (-1 ,3 ,2), (2, 3, -1), (3, 2, -1)])</p>
</blockquote>
<p><strong>Question</strong>: What is the correct input to obtain a best fit polynomial surface going through the six points in $\mathbb{R}^3$? </p>
<p><strong>Edit</strong>: As pointed out by <a href="/users/1092/slelievre/">@slelievre</a>, since these six points lie in a common plane, the corresponding surface should be the plane containing the points. So why does <code>Sage</code> throw an error instead of this plane?</p>
http://ask.sagemath.org/question/42020/correct-input-for-list_plot3d-interpolationspline/?comment=42048#post-id-42048Here's an example (if I understand correctly) of some points having 'nice' x and y coordinates: pts=[(0,0,1),(1,0,2),(0,1,2),(1,1,5)]. Using pts instead of the six points given in the post yields the same TypeError. Can you get a smooth surface from any point set? A single functioning example would be of great help. But I guess I'm off to read the source code: /scipy/interpolate//_fitpack_impl.pycMon, 16 Apr 2018 10:49:14 -0500http://ask.sagemath.org/question/42020/correct-input-for-list_plot3d-interpolationspline/?comment=42048#post-id-42048Comment by slelievre for <p>I'm trying to construct smooth surfaces from lists of points in 3-space using <code>list_plot3d</code> and the <code>spline</code> option, but without success. For example, the input</p>
<blockquote>
<p>list_plot3d ([(-1, 2, 3), (2, -1, 3), (3, -1, 2), (-1 ,3 ,2), (2, 3, -1), (3, 2, -1)], interpolation_type='spline')</p>
</blockquote>
<p>returns the error </p>
<blockquote>
<p>TypeError: m >= (kx+1)(ky+1) must hold</p>
</blockquote>
<p>The following returns the expected piecewise linear surface suggesting that there is a special restriction on the input when using the <code>spline</code> option.</p>
<blockquote>
<p>list_plot3d ([(-1, 2, 3), (2, -1, 3), (3, -1, 2), (-1 ,3 ,2), (2, 3, -1), (3, 2, -1)])</p>
</blockquote>
<p><strong>Question</strong>: What is the correct input to obtain a best fit polynomial surface going through the six points in $\mathbb{R}^3$? </p>
<p><strong>Edit</strong>: As pointed out by <a href="/users/1092/slelievre/">@slelievre</a>, since these six points lie in a common plane, the corresponding surface should be the plane containing the points. So why does <code>Sage</code> throw an error instead of this plane?</p>
http://ask.sagemath.org/question/42020/correct-input-for-list_plot3d-interpolationspline/?comment=42046#post-id-42046Maybe interpolation type 'spline' wants the x and y coordinates
of the points to form a nice grid, and here, because we have six
points not forming such a grid, it is not happy?Mon, 16 Apr 2018 07:38:29 -0500http://ask.sagemath.org/question/42020/correct-input-for-list_plot3d-interpolationspline/?comment=42046#post-id-42046Answer by slelievre for <p>I'm trying to construct smooth surfaces from lists of points in 3-space using <code>list_plot3d</code> and the <code>spline</code> option, but without success. For example, the input</p>
<blockquote>
<p>list_plot3d ([(-1, 2, 3), (2, -1, 3), (3, -1, 2), (-1 ,3 ,2), (2, 3, -1), (3, 2, -1)], interpolation_type='spline')</p>
</blockquote>
<p>returns the error </p>
<blockquote>
<p>TypeError: m >= (kx+1)(ky+1) must hold</p>
</blockquote>
<p>The following returns the expected piecewise linear surface suggesting that there is a special restriction on the input when using the <code>spline</code> option.</p>
<blockquote>
<p>list_plot3d ([(-1, 2, 3), (2, -1, 3), (3, -1, 2), (-1 ,3 ,2), (2, 3, -1), (3, 2, -1)])</p>
</blockquote>
<p><strong>Question</strong>: What is the correct input to obtain a best fit polynomial surface going through the six points in $\mathbb{R}^3$? </p>
<p><strong>Edit</strong>: As pointed out by <a href="/users/1092/slelievre/">@slelievre</a>, since these six points lie in a common plane, the corresponding surface should be the plane containing the points. So why does <code>Sage</code> throw an error instead of this plane?</p>
http://ask.sagemath.org/question/42020/correct-input-for-list_plot3d-interpolationspline/?answer=42038#post-id-42038The six points listed in the question are in the same plane.
One can check that by doing a `list_plot`, or a `point3d`, or by
constructing the polyhedron with vertices the points in the list.
Here are the corresponding commands.
$ sage
SageMath version 8.2.rc1, Release Date: 2018-03-31
sage: p = [(-1, 2, 3), (2, -1, 3), (3, -1, 2), (-1 ,3 ,2), (2, 3, -1), (3, 2, -1)]
sage: list_plot(p)
Launched jmol viewer for Graphics3d Object
sage: point3d(p)
Launched jmol viewer for Graphics3d Object
sage: po = Polyhedron(p)
sage: po
A 2-dimensional polyhedron in ZZ^3 defined as the convex hull of 6 vertices
sage: po.show()
Launched jmol viewer for Graphics3d Object
Mon, 16 Apr 2018 01:39:34 -0500http://ask.sagemath.org/question/42020/correct-input-for-list_plot3d-interpolationspline/?answer=42038#post-id-42038Comment by amdall for <p>The six points listed in the question are in the same plane.</p>
<p>One can check that by doing a <code>list_plot</code>, or a <code>point3d</code>, or by
constructing the polyhedron with vertices the points in the list.</p>
<p>Here are the corresponding commands.</p>
<pre><code>$ sage
SageMath version 8.2.rc1, Release Date: 2018-03-31
sage: p = [(-1, 2, 3), (2, -1, 3), (3, -1, 2), (-1 ,3 ,2), (2, 3, -1), (3, 2, -1)]
sage: list_plot(p)
Launched jmol viewer for Graphics3d Object
sage: point3d(p)
Launched jmol viewer for Graphics3d Object
sage: po = Polyhedron(p)
sage: po
A 2-dimensional polyhedron in ZZ^3 defined as the convex hull of 6 vertices
sage: po.show()
Launched jmol viewer for Graphics3d Object
</code></pre>
http://ask.sagemath.org/question/42020/correct-input-for-list_plot3d-interpolationspline/?comment=42044#post-id-42044Thanks for the answer, but I don't get it yet. Shouldn't the spline approximation through six points in a plane be the plane itself? Also, the same `TypeError` is thrown if I nudge one of the points off of the plane (e.g. the last point is changed to (3,2,0)), so planarity doesn't seem to be the root cause of the error.Mon, 16 Apr 2018 07:05:11 -0500http://ask.sagemath.org/question/42020/correct-input-for-list_plot3d-interpolationspline/?comment=42044#post-id-42044