Tag Info

Hot answers tagged

45

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


28

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


27

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


26

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


17

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`"]; ...


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

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


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


13

That's a good question. There does seem to be a considerable discrepancy versus the 1931 CIE diagram: GraphicsGrid @ List @ Table[ Graphics @ {ColorData["VisibleSpectrum"][i], Disk[], White, Text[i]}, {i, 380, 700, 10} ] Perhaps there was a miscalculation made in reducing the very large CIE color space values to sRGB triplets? sRGB, the ...


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

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


12

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


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

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


12

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


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

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


11

A convenient resource for the Miller Indices can be found here. This ref provides sufficient information for us to draw the (111) and (110) planes. First, reproduce the graphic from the demonstration. I just made the necessary changes to make it run outside of a Manipulate and did not try to optimize it. tet = PolyhedronData["Tetrahedron", "Faces"]; tetv ...


11

So you guys know - quasicrystals are cool structures that can consist of finite number of parts which can be arranged in never repeating - aperiodic - pattern. Thing here is called projection method from a regular lattice. http://www.nature.com/nmat/journal/v3/n11/fig_tab/nmat1244_F3.html Interestingly if you know Fibonacci rabbits problem - that is also ...


10

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


10

The inertia tensor is defined as an integral of the following tensor over the body region vars = {x, y, z}; r2 = IdentityMatrix[3] Tr[#] - # &@Outer[Times, vars, vars]; r2 // MatrixForm It is very simple to do with integration over a region Integrate[r2, vars ∈ region] It can be wrapped in the following function inertiaTensor[reg_, assum_: {}] ...


10

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


9

Wolfram|Alpha is integrated in Mathematica. Integration based on function WolframAlpha. To learn basic interactive and programmatic usage see this question. In your case you can get formatted objects in Mathematica like: WolframAlpha["steam 135C", {{"PhaseDiagramTPPlot:ChemicalData", 1}, "Content"}, PodStates ...


9

The code in the article linked by Alexey produces something similar to this (gradient plot inspired by J.M.'s comment) : Note though that the description of the code does not seem consistent too me, so I had to change it in some places to get this result. Still I hope that I transcribed it more or less correctly. (I wouldn't use this for scientific ...


9

Here is a symbolic solution of your eigenvalue problem. Define the differential equation (setting $\hbar = \omega = m_0 = 1$). diffeq = -(1/2) \[Psi]''[x] + 1/2 x^2 \[Psi][x] == e \[Psi][x] Symbolically solve the differential equation. soln = DSolve[diffeq, \[Psi], x][[1, 1]] (* \[Psi] -> Function[{x}, C[2] ParabolicCylinderD[1/2 (-1 - 2 e), I ...


9

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


9

First take a sample of the real image to get the right color mix: ii = Import@"http://tsgphysics.mit.edu/pics/Q%20Diffraction/Q2-Single-Slit-Diffraction.jpg"; h = ImageTake[ii, {366, 402}, {373, 543}] hd = Transpose[(ImageData@h)[[IntegerPart[ImageDimensions[h][[2]]/2]]]]; Let's see the color curves. It's easy to see that the Red channel is the triple ...


9

I did a solution with contour tracing on the distance function. It gets pretty unstable sometimes, but it's a fun question to experiment with interactivity. DynamicModule[{p1 = {0, 2}, p2 = {1, 3}, angles = {0, 0}, distance, grad, tangent}, distance[a1_, a2_] := Norm[{Cos@a1, Sin@a1} - (Norm[p2 - p1] {Cos@a2, Sin@a2} + p1)]; grad = ...



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