4
$\begingroup$

I want to smooth a unit step function for use in NDSolve so this function is a smooth function of time (t). How can I do the smoothing? The unit step function is defined by:

α = π/6;
Vbusd[t_] := 5 (1 - Exp[-t]);
Vbusq[t_] := 3 Exp[-t];

n = UnitStep[Vbusd[t]*Cos[t - α - π/6] - Vbusq[t]*Sin[t - α - π/6]]  -
    UnitStep[Vbusd[t]*Cos[t - α - (5 π)/6] - Vbusq[t]*Sin[t - α - (5 π)/6]]; 
$\endgroup$
3
  • $\begingroup$ After a second look I think your question is a little unclear. What do you really want? Smoothen n with NDSolve or find a smooth approximation of n which is to be used in NDSolve? $\endgroup$
    – xzczd
    Jun 21 '15 at 9:17
  • $\begingroup$ Thanks alot for help. finding a smooth approximation of n which is to be used in NDSolve. $\endgroup$
    – mard
    Jun 21 '15 at 9:21
  • 1
    $\begingroup$ I normally use Tanh $\endgroup$
    – yohbs
    Jun 21 '15 at 10:48
3
$\begingroup$

These are the transitions I usually use: (both are $C^{\infty}$)

f[x_] = Piecewise[{{(Erf[Sqrt[2 π] ArcTanh[x]] + 1)/2, -1 < x < 1}}, UnitStep[x]]
g[x_] = Piecewise[{{(Tanh[Sqrt[2] Tan[π/2 x]] + 1)/2, -1 < x < 1}}, UnitStep[x]]

Plot[{UnitStep[x], f[x], g[x]}, {x, -2, 2}]

Picture

$\endgroup$
2
  • 1
    $\begingroup$ Could you please post text (code-styled markdown) that can be cut and pasted rather than images of your code? This makes it easy for people to grab your solution and experiment with it. $\endgroup$
    – dionys
    Jun 21 '15 at 12:45
  • 1
    $\begingroup$ But I do not know time of rising and falling levels for difinition of unitstep and Tanh ! $\endgroup$
    – mard
    Jun 21 '15 at 13:24

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.