Tag Info

New answers tagged

1

You can use CellPrint together with ExpressionCell: Plots[o_, r_, t_ : 50] := Module[{a, b, c, d}, a = Plot[f1[x], {x, o, r}, Ticks -> {{t, 2 t, 3 t, 4 t, 5 t, 6 t, 7 t, 8 t, 9 t, 10 t}, {0, 0.2, 0.4, 0.6, 0.8, 1}}, PlotLabel -> "Plot1"]; b = Plot[f2[x], {x, o, r}, Ticks -> {{t, 2 t, 3 t, 4 t, 5 t, 6 t, 7 t, 8 t, 9 t, 10 ...


0

I am assuming your inclusion of t is an error. There is no reason you would want the range of ticks to be unrelated to the domain of your plots. (Your question would allow the plot to be between x = 0 and x = 1 and your Ticks go up to 500, for instance.) Perhaps you want to set number of ticks to be t. Here's what I think you want: f[x_] := {x^2, x^3, ...


1

Here's my attempt to plot the Mandelbrot set with Monte Carlo randomization: mand = Compile[{{z0, _Complex}, {imax, _Integer}}, Module[{z = z0, i = 0}, While[i < imax && Abs[z] <= 2, z = z^3 - 2 z + 2; i++]; i], Parallelization -> True, RuntimeAttributes -> Listable(*, CompilationTarget->"C"*)]; n = 10^6; range = 2; ...


4

This has been fixed in 10.1 (windows) code ClearAll[x] Block[{x}, x::test1 = "message1"]; x::test1 ClearAll[x] Block[{x}, Messages[x] = {HoldPattern[x::test2] :> "message2"}]; x::test2 Block[{x}, x /: x::foo = "bar"; Message[x::foo]]; Messages[x]


3

It is a little known fact and probably not well documented, but since version 9 one can use just strings as variables (dependent and independent) in NDSolve, which in this case helps to solve the memory problem in a rather elegant way: mpl=1/Sqrt[6.70837*10^-39]; gsT=106.75; Sup[LamdaI_?NumericQ,GammaI_?NumericQ]:=Module[{ a,rhor,Trad,tf,s,t }, ...


0

From the comments that Szabolcs gave, Clear and ClearAll are ineffective, but using Remove works. So now the module reads: Sup[\[CapitalLambda]I_?NumericQ, \[CapitalGamma]I_?NumericQ] := Module[{a, \[Rho]r, Trad, tf, s, t, result}, tf = 10/\[CapitalGamma]I; s = NDSolve[{a'[t] ==a[t]*Sqrt[(8 \[Pi])/(3 mpl^2) (\[Rho]r[t] + ...


3

You can also use RandomVariate with DiscreteUniformDistribution: rW[a_, b_, n_] := Accumulate[Prepend[ RandomVariate[DiscreteUniformDistribution[{{-a, a}, {-b, b}}], n]], {0,0}] dt = rW[10, 20, 100]; Graphics[{PointSize[Large], Red, Point@#, Thick, Blue, Line@#} &@dt, Frame -> True, Axes->True, AspectRatio -> 1/GoldenRatio] We get the ...


1

a = 3; b = 5; randomWalk = NestList[# + {RandomInteger[{-a, a}], RandomInteger[{-b, b}]} &, {0, 0}, 100] (* {{0, 0}, {2, 2}, {1, -3}, {-2, 2}, {1, 4}, {1, 3}, {1, 2}, {4, 0}, {4, 0}, {3, -4}, {4, -1}, {2, -5}, {0, 0}, {0, 0}, {2, -3}, {3, -6}, {2, -11}, {4, -10}, {4, -5}, {7, -3}, {9, \ -3}, {6, -8}, {9, -12}, {7, -16}, {5, -11}, {6, -16}, {4, ...



Top 50 recent answers are included