Question: Calculating a "distance integral"

In the attached file, I would like to practice calculating distances between the exact and approximate functions using the "Minimize" function. However, the approach using the integral metric according to (4) produces an error message. I am unable to correct this and would appreciate some advice.test.mw
 

restart

with(Optimization)

assume(0 <= r and r <= 100*Pi)

"term(a,b,c,d,r):=(exp(sin(r))-(a&lowast;sin(b&lowast;r+c)+d));"

proc (a, b, c, d, r) options operator, arrow, function_assign; exp(sin(r))-a*sin(b*r+c)-d end proc

(1)

Minimize(term(s, t, u, v, r)^2, {-100 <= s, -100 <= t, -100 <= u, -100 <= v})

[0.443734259186819141e-30, [r = HFloat(0.8573907336951694), s = HFloat(1.0651237756780674), t = HFloat(0.9373750940497176), u = HFloat(0.9414213728272717), v = HFloat(1.0810520913486565)]]

(2)

Minimize(abs(term(s, t, u, v, r)), {-100 <= s, -100 <= t, -100 <= u, -100 <= v})

[0.206279437975354085e-12, [r = HFloat(0.8598182185084339), s = HFloat(1.0763500233776817), t = HFloat(0.9650602699090793), u = HFloat(0.9650599306574976), v = HFloat(1.0839652198942415)]]

(3)

"term1(a,b,c,d):=(&int;)[0]^(2&lowast;Pi)(term(a,b,c,d,r))^(2)&DifferentialD;r;"

proc (a, b, c, d) options operator, arrow, function_assign; int(term(a, b, c, d, r)^2, r = 0 .. 2*Pi) end proc

(4)

Minimize(term1(s, t, u, v), {-100 <= s, -100 <= t, -100 <= u, -100 <= v})

Error, (in Optimization:-NLPSolve) integration variable previously assigned, 2nd argument evaluates to 1. = 0 .. 2*Pi

 

NULL


 

Download test.mw

 

Please Wait...