Some algorithmic texture generation with Mathematica

The LineIntegralConvolutionPlot[] function in Mathematica is defined by the Wolfram Mathematica Documentation Center as :

LineIntegralConvolutionPlot[{vx,vy},{x,xmin,xmax},{y,ymin,ymax}]
generates a line integral convolution plot of white noise with the vector field {vx,vy}.

LineIntegralConvolutionPlot[] can also generate the plot of an image convolved with a vector field .

I will give some plots of line integral convolutions of a number of vector fields . These plots have often visually appealing forms.

Here is the first plot :

line integral convolution

The Mathematica code for the image above is :

Mathematica code 1

Below are some more line integral convolution plots using various “ColorFunction” options .The frame has been removed from these plots :

This slideshow requires JavaScript.

And below is another line integral convolution plot with the external frame modified with Photoshop . Looks like a nice piece of art … 

plot with frame

 

The Mathematica code for the image above is :

code for plot

 

A last example of a line integral convolution plot with a large size :

output-3b

Mathematica code for the image above ;

code

For more information about this subject see for example the Wikipedia article about  Line Integral Covolution .

Advertisements

The equations of electrodynamics , tensors , and gravitation-First Part

The featured image above was made with Mathematica . It represents  the propagation of an electromagnetic wave.

Elements of this post were written for an answer I gave at quora.com , the question was about Maxwell’s equations
in tensor form. I have modified the answer and added material and equations related to General Relativity and gravitation. 

Maxwell’s equations are the fundamental equations of classical electromagnetism and electrodynamics. They  can be stated in integral form , in differential form (a set of partial differential equations) , and in tensor form.

The conventional differential  formulation of Maxwell’s equations in the International System of Units is given by:

Maxwell's equations differential form

In the above equations , E is the electric field (vector field) , B is the magnetic field ( pseudovector field) ,  ρ is the charge density , and  J is the current density.
ε0 is the Vacuum permittivity ,
and μ0 is the Vacuum permeability .

The second and third equations above form the first group of Maxwell’s equations (the generalized Faraday’s law of induction and Gauss’s law for magnetism) , and the the first and last equations above form the second group  (Gauss’s law and Ampere’s circuit law extended by Maxwell) .

The equations of electromagnetism (Maxwell’s equations and the Lorentz force) in covariant form (invariant under Lorentz transformations) can be deduced from the Principle of least action .

The electromagnetic wave equation can be derived from Maxwell’s equations , its solutions are electromagnetic (sinusoidal) waves.

All the steps and equations related to the topic of this post will not be shown here because they would  make the post much too long , but an overview of the equations , calculations and derivations  will be presented.

The development of the components of the Lorentz force and (after some calculations) its formulation in tensor form allows the introduction of the electromagnetic field tensor Fij :

Lorentz force

where uj is the four-velocity four-vector .

The variation of the action δS with respect to the coordinates of a particle gives the equations of motion. 

The action for a charged particle in an electromagnetic field can be expressed as:

action variation
q is the electric charge.

The variation of the action gives:

variation of action

After some calculations and an integration by parts the variation of the action becomes:

variation of action and integral

In the equation above , ui is the four-velocity four-vector.

Since the trajectories of the particle are supposed to have the same initial and final coordinates , the first term in the right-hand side of the equality above is equal to zero.
The potentials are a function of the coordinates , and  the following equalities can be used:

potential variation

Which gives for the variation of the action:

variation action & potential

Thus the electromagnetic field tensor emerges  from the variation above ; in fact the electromagnetic tensor is given by the definition:

electromagnetic tensor

 

Ai is the electromagnetic four-potential comprising the electric scalar potential V and the magnetic vector potential A .

The electromagnetic tensor is antisymmetric:

antisymmetric tensor

And the diagonal components in it are equal to zero:

diagonal components

 

The components of this tensor can be found using:

potential and field definition

For example:

tensor components

The others components can also be calculated and one gets for the covariant electromagnetic tensor:

electromagnetic tensor components

The components of the contravariant tensor can be found using:

contravariant tensor

where g^{\text{ij}} is the Metric tensor.

The transformation laws for the electromagnetic tensor are given by the general relation:

tensor transformation law

The following equation :

Maxwell equations first group

gives the first group of Maxwell’s equations .

 

If the Levi-Civita tensor ( e^{\text{ikmn}} ) is used ( a completely antisymmetric 4th rank tensor) , one gets for the first group of equations:

Levi-Civita tensor

Using the expression of the action with the Lagrangian density and taking the variation of the action as stationary:

Lagrangian

The last relation above represents the Lagrange equations. And the electromagnetic tensor  Fik is assumed to have been found and defined after developing the Lorentz force.

The relations above give:

Lagrangian equations
Thus Lagrange’s equations give the result:

Lagrange's equations Maxwell  result

And the second group of Maxwell’s equations is given by :

Maxwell equations second group

The second group of equations also gives the equation of charge conservation :

charge conservation
Another notation (the comma notation) and an additional way to write Maxwell’s equations in tensor form are the following :

Maxwell equations tensors comma notation

 

In a gravitational field the electromagnetic tensor is given by:

electromagnetic tensor gravitation

\nabla _j is the covariant derivative and \Gamma _{\text{ij}}^k  are Christoffel’s symbols .
So the relation between the electromagnetic tensor and the potentials is unchanged in the presence of a gravitational field.

The first and second groups of Maxwell’s equations become :

first and second group Maxwell equations

 

After calculation the first group can be shown to be equal to the original first group of equations without gravitation.

The second group can be expressed as:

second group with gravitation

where g is the determinant of the metric tensor.

The equations of motion of a particle of charge q in the presence of an electromagnetic field and a gravitational field are given by  :

equations of motion

Or equivalently:

motion of partilce

In General Relativity , the energy-momentum tensor Tij of an electromagnetic field in free space is expressed in the form of the electromagnetic stress- energy tensor:

energy momentum tensor
And the Einstein field equations

Einstein field equations.

are called the Einstein-Maxwell equations.

To be continued…

Question: what is the square root of 36 ? – Part Two

I will continue with answers and results equal to the square root of 36 ( originally answered at quora.com ). This time the results are mostly related to physics.

With physics one has to take into account the units and the corresponding dimensions of the equations and of the constants.

6 and the square root of 36 are dimentionless numbers , so the result must be dimentionless .
If the result is a simple fraction with numerator and denominator , then the units usually cancel out.
In other cases when one deals with logarithms one should multiply with the inverse dimensions to get a dimentionless result.
In one or two results where I didn’t look for the inverse units  I multiplied the equation with a quantity I called (U) ,  which represents the inverse of the units by which one should multiply the result to get a dimentionless number.

Here are the results :

square root of 36 physics

 

One possible way to explain what I have done here is the following:
If some people , living on an isolated fictitious island or on an another hypothetical planet , attached a great importance to and had a fixation on  the square root of 36 (or the number 6) for one reason or another , and got accustomed to the use of 6 as a fundamental constant ,  unit or number , then they would have likely  tried to construct a system of measurement  based on the number 6 , and  to express physics and math formulas ,equations , constants and rules in relation to 6.

After all , 6 or \sqrt{36} is equal to :

  • The floor of  2 \pi :
    2 \pi \approx 6.2831853071795864769 ;6=\lfloor 2 \pi \rfloor
  • \frac{1}{60} of the circumference of a circle in degrees.
  • It is also  one tenth of 60 seconds which make up a minute , one tenth of 60 minutes which make up an hour , one fourth of 24 hours which equal a day on Earth , one half of  12 months which make up a year , etc.
  • A peculiar ‘hexacentric’ system , so to speak.

Or this can be seen as a (creative) exploration of or exercise in advanced math and physics in order to express many equations , formulas and constants in relation to the number 6 (or \sqrt{36} ) .
Or whatever.

Apologies to Isaac Newton , Leonhard Euler , Bernhard Riemann , Einstein , Stokes , Coulomb , Avogadro , Lagrange , and others (wherever they may be) , for playing around with their equations , formulas , constants , and/or functions.

And one more addiction to this answer :

Does the future of humanity depend on answering what is the square root of  36 , or not?
Have philosophers from Antiquity to the present overlooked this fundamental question , which goes beyond the Kantian categories of space and time set out in his Critique of Pure Reason , and beyond Nietzsche’s Beyond Good and Evil , ushering the transmutation of all values and a defining moment for a new era  in the history of Humankind?
It’s just a square root , for common sense’s sake (or is it?).

Anyway , enough philosophizing.

Here are ( 3=\frac{\sqrt{36}}{2} ) more answers to \sqrt{36} , this time with images :

\sqrt{36}  is equal to :


The number subjected to a geometric rotation in the following image (done with Mathematica and some Photoshop) :

number 6 rotated

The number expressing the power and the coefficients in the equation of the curve in the polar plot below :

number 6 polar plot

The number expressing the degree of the root  and the power of the variables in the 3D plot below :

sinc number 6

The rotated number  and the polar plotted curve in the first two images  above seem to exhibit symmetry.
Symmetry is an very important property in science , math , physics , equations , nature , and wherever it is found.

Online sources and reference works related to what I have written in this answer can be found in my pages about Science books problem solvers and philosophy books in this site/blog.

Some other online sources:
http://mathworld.wolfram.com/

http://en.wikipedia.org/wiki/Category:Mathematics

http://en.wikipedia.org/wiki/Category:Physics

Question: what is the square root of 36 ? – Part One

I went over to www.quora.com a few weeks ago to answer a question about calendars , and then I got busy there. Since I am able to answer different types of questions , I started answering one question after the other , and I got stuck . I mean it’s a good way of getting stuck , answering questions about culture and science is useful and educational , but it can  become time consuming and it requires attention and dedication.

Anyway . somebody came up with a question about the square root of 36. This question was obviously a stale unoriginal question , probably meant as a joke , but I decided to spice it up a little and make it more interesting.
So I answered the question my own way ,  and I got a  good amount of likes and ‘upvotes’ .

I will rewrite the answer  I gave in here (with some modifications ).

Here are some results equal to \sqrt{36}  :

 

square root 36 results one

 

An here is another group of results equal to \sqrt{36} .
If one tries to work out or verify  these equalities , it would be a good exercise in intermediate and advanced math ( and physics).

 

square root of 36 results two

To be continued in another post.

On the linear relation between two calendars

Given a date in the Islamic calendar , there is a formula which gives a good (approximate) numerical value of the corresponding date in the Gregorian calendar.

To find this formula or relation ,  we note that the ratio of a mean (lunar) year of The Islamic calendar to a solar year is:

\frac {354 + \frac {11} {30}} {365.242} = 0.970224

The first year of the Islamic (Hijra or Hegira) calendar started 19th July 622 according to the Gregorian calendar. 19th July is the 200th day of the year and is (approximately ) 0.5476 in parts of the solar year ,while the number of years elapsed is equal to ( y-1) . The days are distributed regularly in both calendars , so the date of the beginning of the year y in Gregorian years is :

0.970224 (y-1)+622.5476

which can be written as :

y_ {\text {ch}} = 0.970224 y_ {\text {hj}} + 621.5774     (1)

Solving the equation above for the year of the Islamic calendar we get:

y_ {\text {hj}} = -640.653499 + 1.03069 y_ {\text {ch}}    (2)

If we try to take a more accurate value for the average year length of  the Gregorian calendar  and take into account additional decimal digits , we get the following slightly more precise formulas replacing the two formulas (1) and (2) above :

yhjtoch(t) = 621.5773576247731 + 0.9702237766245703 t

and:

ychtohj(t) = -640.6536023959899 + 1.0306900573793625 t

 Now if we solve the two equations (1) = (2) above or yhjtoch(t) = ychtohj(t) , we should find the date when the two calendars are equal and have the same day of the same month of the same  year . Solving (1) = (2) gives the result 20875.052079 , which corresponds to 19 days  (0.052079×365 ≈ 19) of the year 20875 , or 19th January 20875 , or 19/1/20875 .
yhjtoch(t) = ychtohj(t) gives the result 20874.956161756745132 , which corresponds approximately to the 349th day of the year 20874 , 16 days before the end of the year.
Using a calender converter (within Mathematica  or an online converter ) , we find that the dates when the two calendars are equal lie between 1/5/20874 and 30/5/20874 , i.e the first day of the 5th month (May) of the year 20874 in the Gregorian calendar is also the first day of the 5th month of the year 20874 in the Islamic calendar , and this goes on until the 30th day of the 5th month of the year 20874 in both calendars. Therefore we can see that the dates obtained by making equal the two sets of equations above deviate and are further away from the real dates verified with calendar converters.

From the beginning of the Islamic calendar to the year 20874 there is a very small increase in the difference between the days of the year for the Islamic and the Gregorian calendar, and for the year 20874 the difference between the 2 calendars (if we equate ychtohj(t) and yhjtoch(t) ) is about 215 days , so I made some calculations and I subtracted a small term (0.000001758733 times t) from the formula converting from the Islamic to Gregorian calendar yhjtoch(t) and I got the following :

yhjch(t) = 621.5773576247731 + 0.9702237766245703 t – 0.000001758733 t

yhjch(t) = 621.5773576247731 + 0.9702220178915703 t

yhjch(t) is a little more accurate than the equation (1) above , which differs from the real date by approximately one day for years and dates in the current (21st) century , then the gap widens between yhjch(t) and (1) , with yhjch(t) giving dates a little before the real date , and equation (1) a little after the real (Gregorian calendar) date.For the year 20874 yhjch(t) gives more precise dates.

Setting ychtohj(t) = ychj(t) and solving ychj(t) = yhjch(t) , we get the result 20874.349006727632514 ,which is a date that lies within the interval between 1/5/20874 and 30/5/20874 for the two calendars.

Below is a graph showing ychj(t) and yhjch(t) around t = 20874 and how they intersect :

graph for the conversion equations of two calendars and how they intersect

So the two conversion formulas or linear equations ychj(t) and yhjch(t) can be considered to be the two most accurate ones for converting between the Islamic and Gregorian calendars.

Additional reference work related to this post :
Time measurement and calendar construction , by Broughton Richmond.

Pi in the sky , and on the computer

Results and things  related to pi are usually published or made known on Pi Day . But you never know when you get inspired by π or find time to explore this ‘venerable’ math constant , and I have already published a post about pi on Pi Day . By the way there is also a Pi approximation Day (July 22) , so there’s more than one date to talk or write  about π .

Let’s kick off with an image of the value of pi (in the clouds ) with 12 decimal digits , made with Photoshop.I tried to make it realistic and show π and its numerical value ( 3. 141592653589) as part of the clouds and the sky.

pi in the shy and in the clouds

Click on the image above to see and enlarged version.

Now for some computer-based mathematical explorations related to π.
There is a known relation between e ( the base of the natural logarithm ) and π :

e^{\pi }-\pi =19.999099979 and is approximately equal to 20 or almost 20 , which is known as an almost integer.
If we try to be more accurate and find the first 1000 decimal digits for the expression above we get (with the help of Mathematica) the following number:

19.99909997918947576726644298466904449606893684322510617247010181721652594440424378488893717172543215169380461828780546649733419980514325361299208647148136824787768176096730370916343136911881572947102843075505750157713461345968680161070464780150721176248631484786057786790083331108325695374657291368002032330492961850463283115054452239990730318010838062172626769958035434209665854687644987964315998803435936569779503997342833135008957566815879735578133492779192490846222394896357465468950148911891909347185826596341254678588264050033689529697396648300564585855142666534919457239163444586998081050100236576797224041127139639108211122123659510905094871070706680635934325684092946890616346767578519812785089761055789304041857980123101280905543416254404987679233496308302396952371198509012175432057419088516489412743155057902167919927734272964964116423666794634333328342687902907792168390827162859622042360176355034576875485783678406122447755263475337650755251536818489395213976127148481818560841182505647  ,
which shows that e^{\pi }-\pi does not approach 20 completely or uniformly.

Here are some more expressions and calculations  involving π (calculated with Mathematica):

pi to the power pi
pi to the power pi and 3
powers of the square root of pi
pi and e twice powers

I think it remains to be seen if the numbers above are transcendental. The Mathematica (version 10)  command Element[z , Algebraics ] cannot determine whether these numbers belong to the domain of algebraic numbers or not.

Now let’s consider an expression containing π , e and i (the imaginary unit complex number). The following expressions are equivalent:

pi ,i ,e and z

A 2D complex plot of the last function above (with z between -4 and 4) gives the following graph (made with Maple):

2 D graph with pi ,e,i and z

A 3 D complex plot of the same function ( with z between -4-4i and 4+4i)   gives the following graph (with the help of Maple):

3 D graph of function with pi ,e and i

A general solution of the function f(z) above for f(z) = 0 is (calculated with Mathematica):

function of z qith pi ,i and e

Here is an interesting result:

Using the Mathematica commands Element[z , Algebraics ] and Not[Element[z , Algebraics ]] , it seems that the solutions z of f(z)=0 above ( for different values of the constants ) do not belong to the domain of algebraic numbers , and are therefore  transcendental numbers.

And with this I bid π farewell for now.

A note about the sinc function as a solution to a differential equation

The (infamous , or famous , take your pick) sinc function is known to be one of two solutions of the differential equation:

differential equation with sinc function as a solution

This is a linear second order ordinary differential equation with dependent variable x and independent variable y.
I have tried to explore and find the solutions to this differential equation using mostly computer math software and programs.

The Texas Instruments 92 Plus scientific calculator and the Maple computer algebra system agree and give the same solution :

sinc solution to differential equationMathematica gives the following solution:

solution with expAfter converting the exponentials to trigonometric functions the expression above and the solution of the differential equation given by Mathematica becomes:

 Mathematica sinc solution

This solution is less simple than (1). Note that if we make the assumption in Mathematica that λ > 0 ,we get the solution:

solution with lambda positiveIf we try to find the graphical representation of solution (1) for different values of the arbitrary constants c1 and c2 and with λ (or n ) between -3 and 3 ,we get the following graphs:

sinc 2d graphs solution

Then I tried to take the absolute value of λ in the numerator of (2) for different values of the arbitrary constants , and compared their graphs  with the graphs of solution (1) for the same values of the constants. λ in (2) and n in (1) are between 1 and 4.graphs of sinc solution of differential equation

The graphical results are similar but not exactly the same.

Using the Manipulate built-in function in Mathematica , here is an animation of the graphs for solution (1) obtained by varying λ , c1 and c2:

Finally , I will give the solution of a generalized form of the differential equation above

general form of differential equation

obtained with Mathematica :

solution of generalized differential equationIn the solution above , Jμ(x) is the Bessel function of the first kind , and Yμ(x) is the Bessel function of the second kind.

Some more 3D graphics related to the sinc function

I’ll finish exploring the sinc function by showing a few 3D graphs of sinc related curves.
Here is a first set of 3D curves of sinc related functions:

This slideshow requires JavaScript.

As an example , here is the Mathematica code for the 3D curve √(x² + y²)sinc(√(x² + y²)) above:

sinc code sqrt

And here is the second set of 3D surfaces related to sinc:

This slideshow requires JavaScript.

The Mathematica code for the curve given by sinc(x² -y²) is:

sinc 3d surface squared

I’m somewhat fed up with sinc , so soon I will move on to other subjects.

Update: I will add a last group of six 3D curves related to sinc . They include curves where sinc as a function of x is multiplied by sinc as a function of y , such as sinc(x)×sinc(y) , sinc(ln(x))×sinc(ln(y)) with ‘ln’ the natural logarithm to the base e  rendered as ‘log’ by Mathematica in the image , sinc(sin(x))×sinc(cos(y)) , and sinc(x²)×sinc(y²)  .

This slideshow requires JavaScript.

2D and 3D graphics related to the sinc function

After having explored calculus results related to the sinc function , here are a few 2D and 3D graphic results.

I’ll start with the integral :

integral of sinc

The graph of the function above is (made with Mathematica):

sinc functionWe’ll consider more than one way to graph this function in 3D.
First , by taking a specific function of x and y and using the following Mathematica code :

 sinc-sq
We get the 3D result :

sinc 3 d function
We can use the RevolutionPlot3D buit-in function in Mathematica to get the graph of the solid obtained from the function by revolving around the z-axis:

solid around z-axis code

sinc function z-axis
The graph of the solid obtained by revolving about the x-axis is:

sinc function x-axis
The Mathematica code for the graph above is:

code for solid x-axis
And the graph of the solid obtained from the function by revolving about the y-axis is:

3d graph about y-axis
The Mathematica code for the graph above is:

code for graph about y-axis
Next is a comparison  between the 2D graph and the 3D graph of the function sinc(tan(w)):

sinc tan
Below is a  set of six 2D graphs of sinc as a function of hyperbolic trigonometric functions:

2d sinc hyperbolic trigMathematica code for the graphs above( rd will be used in the 3D graphs later):

sinc 2d hyperbolic trig

Here are the six 3D graphs related to the above six 2D sinc graphs:

group of 3d sinc functions  trigonometric

And the Mathematica code for the 3D sinc graphs above:

sinc-3d-test-gen

A few calculus results related to the sinc function

I’ve tried to sink my teeth into the sinc function and obtained the following calculus solutions , mostly by tinkering with Mathematica.

The sinc function is generally defined by:

\text {sinc} (x) = \frac {\sin (x)} {x}

with sinc(0) = 1.
The sinc function is sometimes called the filtering or interpolation function and is often used in digital signal processing and in engineering . Sometimes a distinction is made between the unnormalized sinc function and the normalized sinc function sin(πx)/(πx) , but I’m going to consider mostly the unnormalized function.

Graph of the sinc function (done with Mathematica):

sinc function graph

Here is a table of the jth derivative of sinc(x) for j between 1 and 6:

sinc-deriv-1-6

And for j between 7 and 10:

sinc-deriv-7-10

Another table of derivatives for sinc of x with x to the nth power:

calculus-sinc-1

 

Also :

sinc integral set 4

Si(x) is the sine integral function .

Here is an indefinite integral of sinc(f(x)) with

 f(x)=x^n

sinc-properties-int-1

 

For the definite integral we get:

sinc definite integral

Another indefinite integral :

sinc integral 2

Ei(x) is the exponential integral function .

And below is a table of values for a definite integral of sinc(x) to the jth power:

sinc integral 3