# Tag Info

50

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

38

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

37

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

33

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

31

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: ImageColorOperationsDump$wavelengths ImageColorOperationsDumptris These are a list of wavelengths and their corresponding XYZ color values used by this plot command: ... 28 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_, ... 25 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 ... 22 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 ... 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"]; ... 20 (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 ... 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 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, ... 17 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 ... 16 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 ... 16 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], ... 16 If you define your constants this way, you can write the functions using Sum - and looking at your code, it seems that you wanted to define db=2.46 - if so, then you did not correctly put it in the denominator, it was in the numerator. db = 2.46; k[1] = 4*Pi/(3 db) {0, 1}; k[2] = 4*Pi/(3 db) {-(Sqrt[3]/2), -(1/2)}; k[3] = 4*Pi/(3 db) {(Sqrt[3]/2), -(1/2)}; ... 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 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 ... 15 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 ... 15 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 ... 15 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 ... 15 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 ... 14 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 ... 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 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 ...

14

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

13

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

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

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

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