Hot answers tagged

55

After correcting the syntax errors in the original code, the actual question can be addressed: How to display the four variables x1[t]...y2[t] as an animation in a way that conveys their meaning? The basic idea is to use ListAnimate on a list of frames that I define below: Clear[phi1, phi2, t]; sol = First[ NDSolve[{2*phi1''[t] + phi2''[t]*Cos[phi1[t] - ...


52

This post contains several code blocks, you can copy them easily with the help of importCode. Analytic Solution The analytic solution can be obtained with LaplaceTransform and FourierSinCoefficient. First, make a Laplace transform on the equation and b.c.s and plug in the i.c.s: Clear[f]; f[x_] = x (1 - x); eqn = D[u[t, x], {t, 2}] + D[u[t, x], {x, 4}] == ...


46

You asked for alternative approaches to what you did, so here is one: A completely different approach to the one-dimensional time-independent Schrödinger equation would be to use matrix techniques. The idea is to eliminate the need for NDSolve entirely. For bound-state problems, you can do this by choosing a basis satisfying the condition of vanishing wave ...


41

It took me quite a while, but finally, here's a visualization of the perigee of Flamsteed's comet: I should first note two things: first, some of the needed data for computing the orbit of comet C/1683 O1 was missing in AstronomicalData["CometC1683O1", "Properties"], and I had to pull information from external sources to supplement the information available;...


38

Rather than answering your question as posed, let me instead save you the effort of writing such a function and at the same time demonstrate how it can be done by posting some code that I've already written for this purpose: BeginPackage["CovariancePropagation`"]; Unprotect[var, cov]; ClearAll[var, cov]; SetAttributes[var, HoldAll]; SetAttributes[cov, {...


38

DynamicModule[{t = 0, d = 5, a = .08, base, distortion, pts, r, f, n = 10}, r[y_] := .08 y^4; f[x_] := -2 Pi Dynamic[t] + d x; (*f does not evaluate to a number but FE will take care of that later*) base = Array[List, n {3, 1}, {{0, Pi}, {0, 1}} ]; distortion = Array[ Function[{x, y}, r[y] {Cos @ f @ x, Sin @ f @ x}], n {3, 1}, {{0, Pi}, {0, 1}} ...


37

You could try BilateralFilter: ListLinePlot[{data, BilateralFilter[data, 2, .5, MaxIterations -> 25]}, PlotStyle -> {Thin, Red}] Or alternatively, MeanShiftFilter can produce similar results: ListLinePlot[{data, MeanShiftFilter[data, 5, .5, MaxIterations -> 10]}, PlotStyle -> {Thin, Red}] Third alternative, as mentioned by @Xavier ...


35

Notice: Simon Woods did just this months ago for an answer I missed: Convert spectral distribution to RGB color It seems that it can. By spelunking ChromaticityPlot I found: Image`ColorOperationsDump`$wavelengths Image`ColorOperationsDump`tris These are a list of wavelengths and their corresponding XYZ color values used by this plot command: ...


34

In an presentation by Markus van Almsick, he gives an solution to visualize atomic orbitals using Image3D. Radius wave function (hydrogen): R[n_Integer?Positive, l_Integer?NonNegative, r_] := Block[{ρ = (2 r)/n}, Sqrt[(2/n)^3 (n - l - 1)!/(2 n (n + l)!)] E^(-ρ/2) ρ^l LaguerreL[n - l - 1, 2 l + 1, ρ]] /; l < n full wave function: ψ[n_, l_, m_, r_, ...


30

In order to give one possible answer, I'll just take the isotropic harmonic oscillator in 2D and do a finite-difference calculation by discretizing the xy plane with constant spacing a. Here is the construction of the resulting matrix for the Hamiltonian, h. I assume the origin of our spatial grid (where the potential minimum is) lies at {0,0}, and the ...


30

You can also construct the image from Graphics primitives, which ultimately may give you more control: spectrum[list_List] := Graphics[ {Thickness[0.005], ColorData["VisibleSpectrum"][#], Line[{{#, 0}, {#, 1}}]} & /@ list, PlotRange -> {{380, 750}, {0, 1}}, PlotRangePadding -> None, ImagePadding -> All, AspectRatio -> 1/5, ImageSize -&...


29

I got my CIE color matching functions from here. These are the CIE 1931 2-deg, XYZ CMFs modified by Judd (1951) and Vos (1978). {λ, x, y, z} = Import["http://www.cvrl.org/database/data/cmfs/ciexyzjv.csv"]\[Transpose]; ListLinePlot[{{λ, x}\[Transpose], {λ,y}\[Transpose], {λ, z}\[Transpose]}, PlotLegends -> {"X", "Y", "Z"}] Conversion of color ...


29

Why the original matrix approach fails The question originally showed an attempt at a solution based on converting the differential operator (the Hamiltonian) into a matrix (HMax) by forming a Table of overlap integrals. The functions used in these integrals were the bound-state eigenfunctions of the hydrogen radial equation. Although the matrix obtained in ...


27

Nice "inverse problem". The angle distribution looks to me like a Gaussian. ϕ[x_, y_, z_] := (Pi Exp[-Dot[{x, y}, {x, y}]/2] - Pi/2); V[x_, y_, z_] := Evaluate[Simplify[ComplexExpand[-RotationMatrix[ϕ[x, y, z], {y, -x, 0}].{x, y, 0}/Sqrt[{x, y}.{x, y}]]]]; V[0, 0, z_] := {0, 0, -1}; R = Pi; P = Select[Flatten[Table[Table[{x, y, 0}, {y, -R, R, R/20}],{x, -R,...


26

I developed a reaction-diffusion-advection model of pattern formation in semi-arid vegetation (tiger bush) 20 years ago, which shows a type of Turing instability. Plants ($n$) consume water ($w$) and facilitate each other by increasing water infiltration ($wn^2$ term). The model is set on a hillside so water advects downhill at speed $v$ and plants ...


25

Here is my attempt to figure out how the correct colorspace linearization should be made. I used specially designed test images by Eric Brasseur for comparison of two colorspace linearization algorithms. The first algorithm is just an implementation of the corresponding formulae from the Specification of sRGB made by Jari Paljakka who started the discussion ...


24

My preferred method for this kind of thing is projecting each dimension onto a plane and then combining them together. I think MATLAB has similar functionality. Mind you, the answers and comments on my question about projecting are right in pointing out that this will become inefficient for high polygon counts (essentially more PlotPoints) so if you want to ...


24

I recently revisited this, and found that RegionPlot3D is by far the fastest way to plot orbitals, compared to Image3D and ContourPlot3D. I was surprised by the difference, so I thought it's worth posting this. In addition, I also made the process of choosing the plot parameters automatic, based on simple estimates for the size of the orbital wave function....


24

In the version 10.2, there is a builtin DensityPlot3D function, which can be used to visualize orbitals. a0=1; ψ[{n_, l_, m_}, {r_, θ_, ϕ_}] :=With[{ρ = 2 r/(n a0)}, Sqrt[(2/(n a0))^3 (n - l - 1)!/(2 n (n + l)!)] Exp[-ρ/2] ρ^ l LaguerreL[n - l - 1, 2 l + 1, ρ] SphericalHarmonicY[l, m, θ, ϕ]] DensityPlot3D[(Abs@ψ[{3, 2, 0}, {Sqrt[x^2 + y^2 + z^2], ...


23

You can still use box count, but doing it smarter :) Counting boxes with at least 1 white pixel from ImagePartition can be done more efficiently using Integral Image, a technique used by Viola-Jones (2004) in their now popular face recognition framework. For a mathematical motivation (and proof), Viola and Jones point to this source. Actually, someone ...


23

I don't really know how to automate this. What I show is some form of Cartan-Kuranishi approach: take derivatives (prolongation) and eliminate variables corresponding to higher ones (projection). I took a few based on trial and error. I'll start with your Killing eqns, except I got rid of the "=0" part so they are now expressions. Killexpr = Table[derxd[...


22

(too long for a comment) Plot[{ColorData["VisibleSpectrum"][x][[1]], ColorData["VisibleSpectrum"][x][[2]], ColorData["VisibleSpectrum"][x][[3]]}, {x, 380, 750}, PlotStyle -> {Red, Green, Blue}] It doesn't seem that you'll be able to obtain Yellow (RGBColor[1, 1, 0]) from ColorData["VisibleSpectrum"]; unfortunately, the docs say nothing about ...


22

JM commented: If you want to try things out, use Nylander's second snippet, which is using a Beeman integrator. This looks to be faster than native NDSolve[] for this specific case. Paul Nylander's code is here. Below is a modified version of his code which computes all points simultaneously using the fact that all the operations in Beeman's ...


21

I thought I'd share my attempt at this, even though it doesn't seem to have worked properly. The CIE color matching functions are tabulated in the Image`ColorOperationsDump context which is used by ChromaticityPlot. The context can be loaded by calling ChromaticityPlot and then we can interpolate the data to obtain functions: ChromaticityPlot["RGB"]; {x, ...


21

Note: I added an update below to import position and orientation transformations and view the 3D simulation results in Mathematica. I have used the free program Blender v2.79b to simulate the handling of 100s of complex shapes through a geometrically complex industrial machine with many moving parts including vibrating elements. So, it should be able to ...


20

The most hard part of OP's questions is the latter half of 1st one i.e. solve the problem in a little faster or not so demanding-in-memory way. I've found 2 solutions, one is easy but hard to extend, the other is advanced but general. Let me talk about the simple one first. Simple solution Go back to v8. v7 and v6 probably works, too. Clearly there exists ...


20

Modified Newton Cooling Law implementation and reduced FEA cell length Clear["Global`*"] len = 1;(*length of domain*) end = 5;(*end time*) h = 2;(*convection coefficient*) cpmR = 9;(*heat capacity/mass ratio*) Tinit = 0;(*initial temperature of the bar*) T0init = 100;(*initial temperature of the fluid*) (*Tsol=temperature in the bar,T0sol=temperature on ...


20

Here is a piece of code that is inspired by quantum field theory. The physics background can be found in this physics.SE post. First, we define some auxiliary functions: ClearAll[Δ, corr, reduce, allgraphs] SetAttributes[Δ, Orderless]; corr[{a_, b_}] := Δ[a, b]; corr[{a_, b__}] := corr[{a, b}] = Sum[ corr[{a, List[b]...


20

I managed to debug the code from KerrOrbitGRProject and reproduce the results for the Schwarzschild metric (figures on pp. 7-8) coords = {t, r, θ, φ}; n = Length[coords]; a = 0; ρ = r^2 + a^2 Cos[θ]^2; Δ = r^2 \[Minus] 2*M*r + a^2; tt = 2 M*r/ρ \[Minus] 1; rr = ρ/Δ; θθ = ρ; \ φφ = (Δ + (2 M* r*(r^2 + a^2))/ρ) Sin[θ]^2; tφ = \[Minus]4 ...


19

Update Mathematica 10 introduced ChromaticityPlot which provides internal evidence of a discrepancy. Consider: ChromaticityPlot[ {"RGB", ColorData["VisibleSpectrum"] /@ {570, 600, 700}}, Appearance -> {"VisibleSpectrum", "Wavelengths" -> True}, BaseStyle -> PointSize[0.03] ] Clearly the three values are offset from the labeled wavelengths ...


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