Tag Info

Hot answers tagged

13

The problem relates to the granularity of MachinePrecision numbers. The number 70.329862 is represented as an integer times a power of 2: x0 = SetPrecision[70.329862, Infinity] (* 4949024067128413/70368744177664 *) (The denominator is 2^46.) The machine numbers near this number do not allow for the representation of 70.329862 with $MachinePrecision ...


8

EDIT Input gets different rounding to machine-precision real if it's written in arbitrary precision! RealDigits[70.329862, 2] (* {{1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1}, 7} *) RealDigits[ SetPrecision[70.329862000000000000, ...


7

Try this: Solve[c == 0.0625 + 0.0008*X - 0.0232*Y - 0.0157*Z + 0.0059*X^2 + 0.0112*Y^2 + 0.0160*Z^2 - 0.0063*X*Y - 0.0243*X*Z + 0.0211*Y*Z // Rationalize, Z] (* {{Z -> 1/320 (157 + 243 X - 211 Y - \[Sqrt](-375351 + 6400000 c + 71182 X + 21289 X^2 + 82226 Y - 62226 X Y - 27159 Y^2))}, {Z -> 1/320 (157 + 243 X - ...


6

you could start with a simple hack of your code to extract the intersections; Something like {x1, y1} = Transpose[line]; {x2, y2} = Transpose[RotateLeft[line]]; gr2 = {(x1^2 - x1*x2 + y1*(-y1 + y2)), (y1 - y2)} // Transpose // Most; which can be encapsulated in the ellipseSimLowLevel as follows ellipseSimLowLevel[ellPos_, θ_, aimAt_, refls_, ...


5

My defined function next find {nextpoint, nextdirection} value from {startpoint, startdirection} using NSolve. next[{sp_, sd_}][δ_] := Module[{sol, fp, fd}, sol = NSolve[{{x[φ, δ], y[φ, δ]} == sp + t sd, Abs[t] > 10^(-9), 0 <= φ < 2 π}, {t, φ}, Reals]; sol = If[Length[sol] > 0, sol[[1]]]; fp = {x[φ, δ], y[φ, δ]} /. sol; fd = ...


4

You need to randomize the control initial value, not the name of the symbol associated to the control. Perhaps this is what you want: Manipulate[ With[{f = Table[c[i], {i, n}], controls = Sequence @@ Table[{{c[i], s[i]}, -1, 1}, {i, n}]}, Manipulate[f, controls, Button["Random", Do[s[i] = RandomReal[{-1, 1}], {i, n}]]]], {n, {3, 4, 5}}, ...


4

The first step in debugging is always to narrow down the problem. To do this, you can make ncurve global: DynamicModule[{(* ncurve = {} *) }, EventHandler[ ... Then, you can click on the image and evaluate ncurve in a separate cell: Length[ncurve] 248652 (You can and should put ncurve in a DynamicModule once you're done, of course. But for ...


4

you can also try UnitStep Manipulate[ Plot[{f[u] /. subs, f[u] UnitStep[u - a] UnitStep[b - u] /. subs}, {u, 0, 5000}, PlotRange -> All, Filling -> {2 -> Axis}, Epilog -> {PointSize[Large], Point[{{a, f[a] /. subs}, {b, f[b] /. subs}}]}] , {a, 0, 4000}, {b, 100, 4000}]


4

I am guessing you want to do something like Manipulate[ Column[{Row[{With[{a = a, b = b}, HoldForm[Integrate[f[u] /. subs, {u, a, b}]]], Integrate[f[u] /. subs, {u, a, b}]}, " = "], Plot[{ConditionalExpression[f[u] /. subs, a <= u <= b], f[u] /. subs}, {u, 0, 5000}, PlotRange -> All, ...


2

Not sure if it is what you are after: action[dog_] := Print@StringForm["take dog no.`` for a walk", dog]; RadioButtonBar[Dynamic[dog, (dog = #; action[dog]) &], {1, 2, 3}]


1

Confirmed bug. Can't be fixed in 10.0.2 so we have to wait for next release.


1

Here's the solution I ended up going with: Manipulate[ With[{f = Table[c[i], {i, n}], controls = Sequence @@ Table[{{c[i], 0}, -1, 1}, {i, n}], randomize = Hold@CompoundExpression @@ Table[Hold[c[i] = RandomReal[{-1, 1}]] /. i -> j, {j, n}]}, Manipulate[Append[f, r], controls, {{r, 0}, -1, 1}, Button["Random", ...


1

Your code for your model is wrong. As others are saying, your forcing function is $\cos(\omega t)$. Therefore, you simply use NDSolve to obtain solution. eq =theta''[t] + b/(m L0^2) theta'[t] + g/L0 Sin[theta[t]] -T0 Cos[w t]/(m L0^2); ic = {theta'[0] == Pi, theta[0] == 1}; b = 0.22; m = 1; L0 = 1; g = 9.8; w = 1; T0 = 1; sol = First@NDSolve[{eq == 0, ic}, ...



Only top voted, non community-wiki answers of a minimum length are eligible