@@ -127,9 +127,10 @@ new_sys = changeofvariables(sys, t, forward_subs, backward_subs)
127127D = Differential (t)
128128eqs = [D (x) ~ μ* x + σ* x* Bx, D (y) ~ α* By, D (u) ~ μ* u + σ* u* Bx + α* u* By]
129129def = [x=> 0. , y=> 0. , u=> 0. , μ => 2. , σ=> 1. , α=> 3. ]
130- @mtkcompile sys = System (eqs, t; defaults= def)
131130forward_subs = [log (x) => z, y^ 2 => w, log (u) => v]
132131backward_subs = [x => exp (z), y => w^ .5 , u => exp (v)]
132+
133+ @mtkcompile sys = System (eqs, t; defaults= def)
133134new_sys = changeofvariables (sys, t, forward_subs, backward_subs)
134135@test equations (new_sys)[1 ] == (D (z) ~ μ - 1 / 2 * σ^ 2 )
135136@test equations (new_sys)[2 ] == (D (w) ~ α^ 2 )
@@ -139,4 +140,11 @@ new_sys = changeofvariables(sys, t, forward_subs, backward_subs)
139140@test noise_eqs (new_sys)[2 ,1 ] === value (0 )
140141@test noise_eqs (new_sys)[2 ,2 ] === value (substitute (2 * α* y, backward_subs[2 ]))
141142@test noise_eqs (new_sys)[3 ,1 ] === value (σ)
142- @test noise_eqs (new_sys)[3 ,2 ] === value (α)
143+ @test noise_eqs (new_sys)[3 ,2 ] === value (α)
144+
145+ # Test for Brownian instead of noise
146+ @named sys = System (eqs, t; defaults= def)
147+ new_sys = changeofvariables (sys, t, forward_subs, backward_subs; simplify= false )
148+ @test simplify (equations (new_sys)[1 ]) == simplify ((D (z) ~ μ - 1 / 2 * σ^ 2 + σ* Bx))
149+ @test simplify (equations (new_sys)[2 ]) == simplify ((D (w) ~ α^ 2 + 2 * α* w^ .5 * By))
150+ @test simplify (equations (new_sys)[3 ]) == simplify ((D (v) ~ μ - 1 / 2 * (α^ 2 + σ^ 2 ) + σ* Bx + α* By))
0 commit comments