Tag Info

New answers tagged

2

Fixed the bug in original code Thanks for @Michael E2's good suggestion U_?(VectorQ[#, NumericQ] && OrderedQ[#] &) and smart solution to deal with $u_i=u_{i+1}$ $\frac{u-u_i}{u_{i+p}-u_i} and \frac{u_{i+p+1}-u}{u_{i+p+1}-u_{i+1}}$ coeff[u_, i_, j_, U_] /; U[[i]] == U[[j]] := 0; coeff[u_, i_, j_, U_] := (u - U[[i]])/(U[[j]] - U[[i]]) ...


3

Here is a Fourier Basis approach: ClearAll[FourierBasis2D]; FourierBasis2D[{numx_, numy_}, {λx_, λy_}, x_, y_] := N[With[{ωn = 2 π/λx, ωm = 2 π/λy}, Flatten[ {1}~Join~ Table[ {Cos[ n ωn x] Cos[m ωm y], Cos[ n ωn x] Sin[ m ωm y], Sin[ n ωn x] Cos[m ωm y], Sin[ n ωn x] Sin[ m ωm y]}, {n, numx}, {m, ...


0

You can use ListPlot3D and its InterpolationOrder option. That has built in smoothing. ListPlot3D[points, InterpolationOrder->3] This will give you a cubic interpolation. Close to what you are looking for and built into Mma. EDIT: Well, if the points are evenly spaced which they appear to be. But if not then no as this will not produce a scatter ...


3

Here is one way to deal with repeated entries in U. One can define a function to compute the coefficient, using one rule when $u_i = u_j$ and the general formula otherwise. One might put extra conditions on the patterns in coeff below, but if the function is called only within NBSpline, then one might assume the conditions are met. ClearAll[coeff]; ...


2

Is this the behaviour you need? Solution Unprotect[Power]; Power[0, -1] = 1 Protect[Power] Examples 0/0 0 Explanation Revert to normal Unprotect[Power]; ClearAll[Power]; Protect[Power];


2

I was unable to reproduce your error. I defined a similar piecewise function: dfn[x_] := Piecewise[{{x^2, x > \[Pi]/4}, {x^2 Sin[2 x], x <= \[Pi]/4}}]; PolarPlot[dfn[t], {t, -5, 5}] I then created the same plot using ParametricPlot, like you tried to do: Clear[xof, yof] xof[t_] = dfn[t] Cos[t]; yof[t_] = dfn[t] Sin[t]; ParametricPlot[{xof[t], ...


9

Major update, version 2.0 What changed: Is a different, more clever way of solving the problem. Overcomes most of the issues of previous versions. Problem summary: I will rephrase the problem in simplest terms. There exests a named curve called limacon (french, pronounced [ˈlɪməsɒn], means snail), described by a simple equation $r=a+b\cos{\theta}$ in ...


4

An alternative way to force Interpolation to construct a differentiable interpolation is to specify derivatives at the interior points. To get a good curvature, I used 70% of the vector (difference) between the points adjacent to a given point. xyfn = Interpolation @ Thread @ {List /@ Range @ Length @ points, points, Join[{Automatic}, 0.7 ...


5

As an alternative one can use J.M.'s nice implementation of a spline with centripetal parametrization which gives (IMO) "natural" and undisturbed curve. @belisarius has packed J.M.'s code into a function in this answer (which would be much more suitable here than in that thread because despite large number of upvotes it does not answer the original ...


11

The built-in functionality can do this directly: {xs, ys} = Transpose[points]; xinterp = Interpolation[xs, Method -> "Spline"]; yinterp = Interpolation[ys, Method -> "Spline"]; ParametricPlot[{xinterp[t], yinterp[t]}, {t, 1, Length@points}, Epilog -> Point /@ points] Without the "Spline" method, the interpolating functions are not always ...


11

I appreciate kguler's elegant solution, but it doesn't join the points. To be more precise, it joins only every third point because Bezier line additionally takes 2 anchor points for each point. There are different methods to obtain these points. The simplest one is the following (pictures taken here) In Mathematica it looks like the following code ...


4

llp = ListLinePlot[points, ImageSize -> 500]; llp2 = llp /. Line[x___] :> BSplineCurve[x, SplineDegree -> 2]; Row[{llp, llp2}] where points = {{-0.137445, -0.0103507}, {-0.0452845, 0.0343154}, {0.30498, -0.0118266}, {-0.0224633, 0.0197979}, {-0.168469, -0.0197066}, {0.0973217, 0.0478612}, {-0.0441388, 0.0360607}, ...



Top 50 recent answers are included