1
$\begingroup$

I am trying to get Mathematica to solve for the symmetric limits of an integral of a Square Wave.

Solve[{Integrate[SquareWave[{0.2, 0}, ((x - 2.5)/10)], {x, 0 + a, 
 10 - a}] == 0.95, 0 <= a <= 1}, a, Reals]

I already know that the only solution for $a$ is 0.125. I am just trying to improve my Mathematica knowledge here. When I run the above, it simply returns unevaluated. I have also tried NSolve, and NIntegrate, but neither of those appears to work either.

Any ideas?

Best,

Ben

$\endgroup$
3
$\begingroup$
Solve[{Integrate[ SquareWave[{2/10, 0}, ((x - 25/10)/10)], {x, a, 10 - a}, 
                 Assumptions -> 0 < a < 1] == 95/100,
      0 <= a <= 1}, a, Reals]

(* {{a -> 1/8}} *)
$\endgroup$
3
  • $\begingroup$ Thanks for that. Much appreciated. Why was it that I needed to tell Integrate my assumptions though? I thought that would be handled (and passed down to Integrate) by the 0 <= a <= 1 condition in Solve. Thanks again! Best, Ben $\endgroup$ – ben18785 Mar 24 '15 at 0:51
  • 1
    $\begingroup$ @ben18785 Because the integral behaves differently in different ranges. Try Plot[Integrate[ SquareWave[{2/10, 0}, ((x - 25/10)/10)], {x, a, 10 - a}], {a, -10,10}] $\endgroup$ – Dr. belisarius Mar 24 '15 at 0:54
  • $\begingroup$ Ok - great. I understand it. Thanks again! Best, Ben $\endgroup$ – ben18785 Mar 24 '15 at 0:55
3
$\begingroup$

Alternatively, use FindRoot

FindRoot[Integrate[
   SquareWave[{0.2, 0}, ((x - 2.5)/10)], {x, 0 + a, 10 - a}] == 0.95, {a, .5}]

{a -> 0.125}

$\endgroup$
1
  • $\begingroup$ Thanks for your answer. Much appreciated. Best, Ben $\endgroup$ – ben18785 Mar 24 '15 at 0:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.