New answers tagged

2

Update: If you use r[t] instead of r as the second argument of NDSolve you get the desired functions directly: sol2 = NDSolve[{(1 + (4 A t^2)/(r[t]^2 (r[t]^2 - Zh^2)) + Zh^2/(r[t]^2 - Zh^2) + (4 A Zh^4 t^2)/(r[t]^2 (r[t]^2 - Zh^2)^3) + (8 A Zh^2 t^2)/(r[t]^2 (r[t]^2 - Zh^2)^2))* r'[t]^2 + ((-4 A t)/(r[t] (r[t]^2 - Zh^2)) - ...


2

Here is one way to do it. With[{A = 2.23818*^8, Zh = 1*^11, a = 1.496*^11, M = 1.33*^20}, {rLo, rHi} = NDSolve[ {(1 + (4 A t^2)/(r[t]^2 (r[t]^2 - Zh^2)) + Zh^2/(r[t]^2 - Zh^2) + (4 A Zh^4 t^2)/(r[t]^2 (r[t]^2 - Zh^2)^3) + (8 A Zh^2 t^2)/(r[t]^2 (r[t]^2 - Zh^2)^2)) r'[t]^2 + ((-4 A t)/(r[t] (r[t]^2 - Zh^2)) ...


3

While using a computer often means you don't have to worry if there is a large number of polynomials approximating data piecewise, the OP wishes to find a simple polynomial or two that roughly approximates the data. Here is an approach. Please note that data fitting and smoothing is not my forte; but the mathematics used here is fun and too alluring for me ...


0

What you want to do is actually very simple and can accomplished by a single line of code. With[{db = .01}, v = Interpolation[Table[{b, b^2}, {b, 0, 1, db}]]]; Then Plot[v[b], {b, 0, 1}]


4

In the following da was the data imported using Import.data: removed headers of da; dat is transforming data into cartesian points. dat = Catenate[{{#1, -10, #2}, {#1, 0, #3}, {#1, 10, #4}} & @@@ data]; Show[ListPlot3D[dat, ImageSize -> 300, AxesLabel -> (Style[#, 15, Bold] & /@ {"\[Alpha]", "y", "z"}), Mesh -> False], ...


5

[...] however i would like to build approximation function, that go through as many points as it can. So how can I do that? As What I ideally trying to make is two approximation functions for each half of the graph that go through as many points as it can. This can be easily done with Quantile Regression. Data First let us generate some data: ...


0

In[1]:= b=Range[0,.9,0.1]; Length@b p=Range[.25,.75,.05] Length@p Out[2]= 10 Out[3]= {0.25,0.3,0.35,0.4,0.45,0.5,0.55,0.6,0.65,0.7,0.75} Out[4]= 11 In[5]:= Information@Interpolation; Interpolation[{{{Subscript[x, 1],Subscript[y, 1],\[Ellipsis]},Subscript[f, 1]},{{Subscript[x, 2],Subscript[y, 2],\[Ellipsis]},Subscript[f, 2]},\[Ellipsis]}] constructs an ...


1

you have it close, just need an extra {} on the x term: ( making up a simple example..) n = 4; a = 0; b = 1; f[x_] := 10^12 Sin[2 x] ; f2[x_] := 10^12 Cos[x] ; poly = InterpolatingPolynomial[ Table[{{xi = a + (b - a)/n i}, N@Round[ f[xi], 10^7], N@Round[f2[xi], 10^7]}, {i, 0, n}], x] // Simplify 0.+ 1.*10^12 x + 6.76392*10^13 x^2 - ...


0

I'm not sure why InterpolationOrder -> 2 isn't working for you, but here is a work-around you might use. data = {{0, 0, 1738.946}, {0, 24, 1700.418}, {0, 48, 1698.078}, {32.05, 0, 1772.551}, {32.05, 24, 1736.689}, {32.05, 48, 1722.127}, {64.10, 0, 1999.362}, {64.10, 24, 1969.550}, {64.10, 48, 1919.607}}; plot1a = ListPointPlot3D[data, ...


6

More of an extended comment here, but it is clear that ListPlot must use a different interpolation function than is available via Interpolation. We can get a very close approximation by Janus's answer here and amending the Method option. The idea is that ListPlot performs an parametric interpolation on the x and y axes separately. data = {{1., 5827.}, ...


1

Initialization One alternative is to construct new interpolating functions from the solutions. dsol = x /. First@NDSolve[{x'[ t] == -Sqrt[(1/(4 - 2 Sqrt[2]) + (4 - 2 Sqrt[2])/(2 x[t]))^2 - 1], x[0] == 4}, x, {t, 0, 10}]; msol = Solve[m[t] Sqrt[1 + x'[t]^2] - m[t]^2/(2 x[t]) + 1 == 0, m[t]] (* {{m[t] -> x[t] Sqrt[1 + ...


2

You have your NDSolve xsoln = NDSolve[{x'[ t] == -Sqrt[(1/(4 - 2 Sqrt[2]) + (4 - 2 Sqrt[2])/(2 x[t]))^2 - 1], x[0] == 4}, x, {t, 0, 10}] which returns a replacement rule. This replacement rule will work with derivatives, just try Plot[{x[t], x'[t]} /. xsoln, {t, 0, 10}, Evaluated -> True] to see this. Then you solve the algebraic ...


3

Short Answer You need to set the InterpolationPoints to a higher value than the default in order to get a decent result out of FunctionInterpolation. For this example, 125 is the lowest I found that gives a good plot, testfun[y_, x_] := x/(1 + y^2); intfun = FunctionInterpolation[testfun[y, x], {y, -20, 20}, {x, 0, 2}, InterpolationPoints -> 125]; ...



Top 50 recent answers are included