Tag Info

Hot answers tagged

49

I dug up some simple analog circuit design definitions that I sometimes use to make diagrams for classes or problem sets. Mathematica is obviously very useful when you have to create iterative copies of circuit elements, as in this example (a chain of resistor-capacitor elements): Since this is for teaching purposes and not professional, you may forgive ...


36

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] - ...


30

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, ...


30

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 ...


27

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: ...


24

You can also construct the image from Graphics primitive, 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 ...


23

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_, ...


21

SystemModeler is one of the Wolfram products that allows building and simulating complex electric circuits - stand alone or as coupled to other systems, like thermodynamic or mechanical ones. This is an alternative answer. If you have latest SystemModeler 4 you can visually create a model there and then import it into Mathematica: Needs["WSMLink`"]; ...


21

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 ...


20

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 ...


18

(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 ...


18

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, ...


15

Here is the Mathematica proof. I'll leave out the prefactor $\hbar/i$ for simplicity. Also, in case this is a homework problem, I decided not to add too many comments to the code. Instead I'll let you figure it out. The basic idea is to do cross products and gradients in spherical coordinates. The calculation shown here actually gives you a way to calculate ...


15

I just had a look at the colours as they are produced on my screen. I have been working with lasers for many (30+) years and can assure you that a 591nm laser line is fairly yellow, around 635nm is fairly red and 488nm appears as cyan, which resembles the colours of the disks well. Are you sure you are not confusing the wavelength of the maximum of black ...


15

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 ...


14

It is probably a common student misconception that it is "such a complex function". In actuality, it is quite simple. You should read: A pedagogical example: the Mexican hat potential. Very roughly you get the Mexican hat from interplay between two power functions: a x^4 and b x^2. If parabola b x^2 is inverted you get a bump in the center of your a x^4 ...


14

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 ...


14

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 ...


14

One way is to set up a DAE: See tutorial/DSolveExamplesOfDAEs and example/ModelConstrainedSystemsAsDAEs. The constraint that the driver (bottom rotating link) has a fixed length is taken care of by initial conditions and the DE. There are two possible starting positions for the driven link. One might have to inspect the result of Solve to determine which ...


13

This is a bug (or an imperfection) of ColorData["VisibleSpectrum"]. Others have delved into its root, but in my answer I simply will make it clear by a comparison with an experimental, known single wavelength color[1]: sodium’s D-line at 589.0 nm. Here is Mathematica’s idea of the color of this wavelength, using default settings (no color profile ...


13

By default, Mathematica assumes symbols to be complex. However the elements on the main diagonal of a Hermitian matrix are necessarily real. To force Mathematica to interpret the elements on diagonal of m to be real you could replace them by their real part, i.e. m = {{Re[n], a, b, b}, {Conjugate[a], Re[n], b, b}, {Conjugate[b], Conjugate[b], Re[c], ...


13

Perhaps what you're looking for is something like this: Module[{x, a, b}, x[1] = 1; x[2] = 10; a + b/x[2] + x[1] ] $\text{a$\$$3026}+\frac{\text{b$\$$3026}}{10}+1$ Here I defined a single additional local variable x but then refer to "indexed" variables sharing the same name and differing only in the index x[1] and x[2] etc. These indices are ...


13

If the potential is $(\tanh (x)+1) (\tanh (x)-1)$ you can obtain the analytic solution using Mathematica as follows: [I have omitted some of the detail - e.g. the asymptotic expansions - because the details are analogous to the simple harmonic oscillator case in my previous answer (see above).] Define the potential. u[x_] = (1 + Tanh[x]) (-1 + Tanh[x]) ...


13

The integrals can in fact be done exactly, but only if you make some use of the symmetries of the problem first. The circular ring geometry implies that the magnetic field will look the same in any vertical plane going through the rotation axis (which we call the z axis). Therefore, we don't need to specify three independent variables x, y and z to do the ...


12

In the recent version of Mathematica (version 9), an "approximate" solution to the graph realization problem can be obtained by tuning the repulsive/attractive force in the SpringElectricalEmbedding via EdgeWeight: elength = {2, 4, 2, 4, 3, 4}; g = CompleteGraph[4, EdgeWeight -> elength, EdgeLabels -> "EdgeWeight", GraphLayout -> ...


12

noeckel’s answer on StackOverflow is spot on. This is not a Mathematica issue, this is a mathematical issue. Namely, Mathematica is giving you the correct solution to the system of differential equation and boundary conditions given. The conditions given (and in particular the derivative imposed at the origin) are incompatible with the expected decay. Bear ...


12

Assuming that all the initial positions (x[0], y[0] and z[0]) and the initial velocities (x'[0], y'[0] and z'[0]) are equal to 0 you can do: adat = Rest@Import["http://pastebin.com/raw.php?i=jZ57mqZT"]; {ax, ay, az} = Interpolation /@ (adat[[All, {1, #}]] & /@ {2, 3, 4}); {xt, yt, zt} = (x /. Quiet@First@NDSolve[{ x[0] == 0, x'[0] == 0, ...


12

I prefer ListDensityPlot here as it gives flexibility to plot a range of data points. First of all, I define a function which generates a narrow spectrum around our desired wavelength: spec[wavelength_, width_] := Flatten[Table[{{x, 0, x}, {x, 1, x}}, {x, wavelength - width, wavelength + width, 0.1}], 1]; where we can specify wavelength and width of ...


11

A reasonable alternative, is to construct an explicitly Hermitian matrix by exploiting the fact that any matrix, $M$, can be written as the sum of a Hermitian matrix, $H$, and a skew-Hermitian (or anti-Hermitian, if your in physics) matrix, $S$. This implies that a matrix can be made Hermitian simply by $$H = \frac{1}{2}(M + M^\dagger)$$ or skew-Hermitian ...


11

As Jens mentioned, the spatially discretize the equation is another alternative for bound state problem. Here is my very simple implementation of this approach. The basic idea is express the equation on a grid. The differentials can be expressed as finite differences. For example, the second order derivative can be expressed as $$ \frac{d^2\psi}{d ...



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