Back to MAIN
... some simple analytical ways solving ordinary differential equations (Part 1)
lets a bit k4 talking to J first ..
steps:{(*x)+((--/2#x)%c)*!_ 1+c:*|x:1.0*x}
sqr:{{exp y*log x} . (x;2.0)}
(`:g:/toJplotZ.txt) 0: ,/'" ",''${{.5*-/sqr x,y} . x}''r,/:\:r:steps 0 2 50
(`:g:/toJplotX.txt) 0:t:,,/" ",'$r
(`:g:/toJplotY.txt) 0:t
..some J code ..
load'numeric strings trig plot files'
NB.load 'opengl'
NB.coinsert 'jgl3 jzopengl'
X=.". '-_' charsub (13 10{a.) delstring fread 'g:\toJplotX.txt'
Y=.". '-_' charsub (13 10{a.) delstring fread 'g:\toJplotY.txt'
Z=.". '-_' charsub 'm' fread 'g:\toJplotZ.txt'
'boxed 0;backcolor darkblue;viewsize 1 1 0.65;viewpoint 0.9 _1.4 0.6' plot X;Y;Z
..resulting in the following display:(a hyperbolic paraboloid)
(real graphic is better than the one below - there was some quality loss
during the batch-conversion to JPG)
Sample 1:y cos x - y'sinx = 0
...a simpler one we can do by separation : y = c sin x
The representative K4 list can be done by:
`:g:/ax.txt 0: ,/'" ",''$+(1-(%0.5*l)*!l:30)*/:sin steps 0 20 200
J is picking this up by: plot ". '-_' charsub 'm' fread 'g:\ax.txt'
.. which will end in the following display
(or.. We can also apply J directly in this case: plot |:(1-(%-:t)*i.t=.30) */~sin steps 0 20 200 )
Sample 2:
238U resolves into 206Pb. The half-life of this Uranium is 4.5 bn years.
A probe from the earth's mantle contains 100 mg 238U and 14 mg 206Pb.
How old is the probe, if we assume that the probe did or does not contain
any lead or any other elements or products resolving faster than 238U.
The uranium mass is decreasing linearly with the resolving-constant L..eg
dm/dt = -L m .. solving this gives us m = C e-L t .. and as m(0)=M
follows that C = M.
Using the half-life: m(T) = 0.5M = Me-L t .. eg L = T/ln 2 ..
So, m = M e-(t/T)ln 2. Assuming here a symetric behavior of the lead:
a = A(1 - e-(t/T)ln 2) it follows that t = T ln (1 + b-1)/ln 2
where b = A m / M a. So, t is approx 970 million years.
Sample 3:
Sample 4:
`:f:/f.txt 0: ,/'" ",''$+{x*1+2*atan x*steps -0.25 0.25 40}'steps -3 3 100
Sample 5:
`:f:/f.txt 0: ,/'" ",''$+{-1+c+(steps -4.25 4.25 60)*exp(-c:atan x)}'steps -4 4 200
Sample 6:
`:f:/f.txt 0: ,/'" ",''$+{-2+r*asin (steps -0.45 0.45 60)*r:x+1}'steps -1 1 200
Sample 7:
We look for a mirror surface, that reflects the light coming from one
point, as parallel lines.
Sample 8:
`:f:/f.txt 0: ,/'" ",''$(-r),r:+{%x*x*sqrt (steps -1 200 70)+2*exp x}'steps 0.65 3.5 100
Sample 9:
`:f:/f.txt 0: ,/'" ",''$+{r*-1+%log (steps 0.85 17.1 60)*r:%x}'steps 0.71 3.0 200
Sample 10:
`:f:/f.txt 0: ,/'" ",''$+{(3f*1+K)%((K:(steps -130 130 1000)*exp -6f*v)*v+u)+ ..
+ .. (v :xexp[x;%3f])-u:3f*xexp[x;2%3]}'steps 0.0001 0.45 200
Sample 11:
`:f:/f.txt 0: ,/'" ",''$+{r*-1+r%tan (steps -1.3 1.3 70)+r:%x}'steps -5 5 50
Sample 12:
`:f:/f.txt 0: ,/'" ",''$+{(-asin sqrt a)+(sqrt x*a:1-x)+steps -0.7 0.7 50}'steps 0 1 100
Sample 13:
param:{[fx;fy;xv;cv](((#cv)#,fx xv);(fy xv)+/:cv)}
`:f:/f.txt 0: ,/,/''" ",'''$param . ({x-log x};{(%x)+log x};steps 0.1 8 90;steps -5 5 30)
For this we define in J the mathematical fork f:
f =. 2"_ , -:
plot (f #r)$r=. <"1 ". '-_' charsub 'm' fread 'f:\f.txt'
Sample 14:
Envelopes:
`:f:/f.txt 0: ,/'" ",''$+{c+(x*c)+exp c:steps -2 2 130}'steps -9 9 300
The curve:
(via J, as a combination of two forks and two atop conjuctions)
f =. (>: * (^.@-@>:)) - >:
... plot f steps _8 _1.1 100
Sample 15:
The set N above for Jm is defined as N:{x|x is different from 1}
`:f:/f.txt 0: ,/,/''" ",'''${+x}'{((f1;f2) .\: x)}''t,\:/:c
where:
f1:{(-x)+y*(1%x*x)*exp 1%x} and f2:{(-0.5*x*x)+y*(1+1%x)*exp 1%x}
and
t:(steps (-6 -0.45 20)),steps 0.75 6 25 ; c:steps -5 5 30
The parabola stage we reach for c=0, and each apex represents the infinity
The step in J is:
plot f2 <"1 ".'-_'charsub'm'fread'f:\f.txt'
and where
f2=.|:@(((-:@#),2"_) $ ])
Sample 16:
We look for the curves that build with any line y = kx an angle of 45 degrees.
The handmade graphics below emphasizes how simple the problem is.
We obtain the logarithmic spiral..
`:f:/f.txt 0: ,/,/''" ",'''${+x}'{((f1;f2) .\: x)}''t,\:/:c
where
f1:{y**/(cos;exp)@\:x} and f2:{y**/(sin;exp)@\:x}
Sample 17:
And for C2 = -1 we will obtain:
`:f:/f.txt 0: ,/'" ",''$+{1+0.25*x*(4*steps -2 2 50)+x*3-log x}'steps 0.0 2 70
Sample 18:
Now we choose C2 = 1
`:f:/f.txt 0: ,/,/''" ",'''${+x}'{((f11;f12) .\: x)}''t,\:/:c
where
f11:{x*y+3f*x} and f12:{1f+(x*x*x%60f)*(y*y*10f)+x*(y*75f)+144f*x}
and
t:steps -3 3 50; c:steps -71 71 40
Sample 19:
Now we choose K1 = 0
`:f:/f.txt 0: ,/'" ",''$+{exp (steps -1.6 1.9 27)*(x*s)+q+log x+s:sqrt 1+q:x*x}'steps -0.45 0.55 30
Sample 20:
We choose now c2 = 1
`:f:/f.txt 0: ,/'" ",''$+{1+x+(steps -2 2 30)*exp x}'steps -5 1.2 30
Back to MAIN
©++ MILAN ONDRUS