# Backup diff of Examples (No. 1)

• The added line is THIS COLOR.
• The deleted line is THIS COLOR.
```[[Hybrid Automaton]]

* bouncing_particle [#p560bc2f]
>
~ // bouncing particle
~
~ INIT <=> y = 10 & y' = 0.
~ FALL <=> [](y'' = -10).
~ BOUNCE <=> [](y- = 0 => y' = -4/5*y'-).
~
~ INIT, FALL << BOUNCE.
<
----
>
~ /**
~  *  bouncing particle in f(x) = (1/2) * x^2
~  */
~
~ INIT <=> x = 1/2 & y = 10 & x' = 0 & y' = 0 & [](k = 1).
~ A <=> [](x'' = 0 & y'' = -98/10).
~ /**
~  *     sin = f'(x) / (1+f'(x))^(1/2)
~  *     cos =     1 / (1+f'(x))^(1/2)
~  *  new x' = (-k * sin^2 + cos^2) * x' + (k+1) * sin * cos      * y'
~  *  new y' = (k+1) * sin * cos    * x' + (sin^2 + (-k) * cos^2) * y'
~  */
~
~ SC <=> [](s = (x-)/(1+(x-)^2)^(1/2)
~         & c = 1   /(1+(x-)^2)^(1/2)).
~
~ BOUNCE <=> [](y- = (1/2) * (x-)^2 =>
~                        x' = ( (-k) * s^2 + c^2 ) * x'-
~                             + ( (k+1) * s * c ) * y'-
~                      & y' = ( (k+1) * s * c ) * x'-
~                             + ( s^2 + (-k) * c^2 ) * y'- ).
~
~ INIT, SC, A << BOUNCE.
<
----
* bouncing_particle_rp [#z5246173]
>
~ // bouncing particle with parameter
~
~ INIT   <=> 5 < ht < 15 & v = 0 & e =4/5 & [](ht' = v & e'=0).
~ FALL   <=> [](v'  = -10).
~ BOUNCE <=> [](ht- = 0 => v = -e * v-).
~
~ INIT, FALL << BOUNCE.
<
----
* bouncing_particles [#cd9b6075]
>
~ // many bouncing particles
~
~ INIT(y, y0) <=> y = y0 & y' = 0.
~ FALL(y) <=> [](y'' = -10).
~ BOUNCE(y) <=> [](y- = 0 => y' = -y'-).
~
~ BALL(yarg, y0){INIT(yarg, y0), FALL(yarg) << BOUNCE(yarg)}.
~
~ BALL(y1, 1), BALL(y2, 2),BALL(y3, 3), BALL(y4, 4),BALL(y5, 5),
~ BALL(y6, 6), BALL(y7, 7), BALL(y8, 8). BALL(y9, 9), BALL(y10, 10),
~ BALL(y11, 11),BALL(y12, 12), BALL(y13, 13), BALL(y14, 14).
~ BALL(y15, 15), BALL(y16, 16).
<
----
* circle [#xbf24e18]
>
~ //circle.hydla
~ //bouncing particle in a circle
~
~ INIT   <=> x = 0 /\ 0.5 < y < 0.6 /\ x' = 2 /\ y' = 1.
~ RUN    <=> [](x'' = 0 /\ y'' = 0).
~ BOUNCE <=> []((x-)^2 + (y-)^2 = 1 =>
~                 x' = x'- - (x- * x'- + y- * y'-) * 2 * (x-) /\
~                 y' = y'- - (x- * x'- + y- * y'-) * 2 * (y-)
~ ).
~ INIT, RUN<<BOUNCE.
<
----
* baloon_tank [#tf906f5e]
>
~ /* A program for a hot-air balloon rising by fuel tanks that are exchanged. */
~
~ INIT<=>h=10/\h'=0/\fuel=1/\timer=0
~         /\2<exT<4
~         ///\ exT = 3
~         /\ 1<volume<3.
~
~ CONS<=>[](exT'=0/\volume'=0).
~ TIME<=>[](timer'=1).
~
~ BURN<=>[](fuel=1=>h''=1).
~ FALL<=>[](fuel=0=>h''=-2).
~
~ VOID<=>[](timer->=volume=>fuel=0).
~ FULL<=>[](timer-<volume=>fuel=1).
~
~ COMP<=>
~   [](timer->=volume+exT=>timer=0).
~
~ ASSERT(h>0).
~
~ INIT,CONS,BURN,FALL,VOID,FULL,TIME<<COMP.
<
----
* magnet_ball [#a6ea3f5c]
>
~ /*
~ 重力と磁力の影響を考えたボールの動き
~ 磁力は重力と逆向きに働き、スイッチでＯＮ／ＯＦＦできる
~ スイッチは１秒ごとに切り替えられる可能性がある
~ */
~
~ INIT <=> y=10 & y'=0 & mag=0 & timer=0.
~ FALL <=> [](y''=-10+mag).
~ BOUNCE <=> [](y-=0=>y'=-y'-).
~ TRUE <=> [](1=1).
~ TIMER <=> [](mag'=0&timer'=1).
~ SWITCHON <=> [](timer-=1=>mag=12&timer=0).
~ SWITCHOFF <=> [](timer-=1=>mag=0&timer=0).
~ SWITCHW <=> [](timer-=1=>mag=100&timer=0).
~
~ INIT,TIMER<<(SWITCHOFF,SWITCHON,SWITCHW)<<TRUE,FALL.
<
----
>
~ INIT   <=> x=3/4 /\ y=0 /\ x'=2 /\ y'=1.
~ RUNX    <=> [](x''=0).
~ RUNY    <=> [](y''=0).
~ WALL1 <=> []((x- - 1)^2+(y-)^2=1 & x > 1=>
~     x' = x'- - ((x- -1)*x'- +y*y'-)*(1+1)*(x- -1) /\
~     y' = y'- - ((x- -1)*x'- + y-*y'-)*(1+1)*(y-)).
~ WALL2 <=> []((x- + 1)^2+(y-)^2=1 & x < -1=>
~     x' = x'- - ((x- +1)*x'- +y*y'-)*(1+1)*(x- +1) /\
~     y' = y'- - ((x- +1)*x'- + y-*y'-)*(1+1)*(y-)).
~ WALL3 <=> [](y- = 1 => y' = -y'-).
~ WALL4 <=> [](y- =-1 => y' = -y'-).
~
~ INIT, (RUNX, RUNY)<<(WALL1,WALL2,WALL3,WALL4).
<
----
* throw_ball [#wd37993f]
>
~ // throwing ball against head wind
~
~ INIT <=> x = 0 & y = 10 & x' = 10 & y' = 10 & 5 <= y' <= 15.
~ FALL <=> [](y'' = -10).
~ WIND <=> []((y- >= 15 => x'' = -3) & (y- < 15 =>  x'' = 0)).
~
~ INIT, FALL, WIND.
~
~ //ASSERT(!(x >= 25 & y > 0)).
<
----
* roof_bouncing [#e682ba1f]
>
~ // bouncing particle to a roof
~
~ INIT <=> 9 < y < 11 & y' = 10.
~ FALL <=> [](y'' = -10).
~ BOUNCE <=> [](y- = 15 => y' = -(4/5)*y'-).
~
~ INIT, FALL << BOUNCE.
<

```