login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

Ref.

Derivative of abs

fricas
s1:=D(abs(x),x)

\label{eq1}{abs \left({x}\right)}\over x(1)
Type: Expression(Integer)
fricas
D(s1,x)

\label{eq2}0(2)
Type: Expression(Integer)
fricas
limit(abs(x)/x,x=0,"right")

\label{eq3}1(3)
Type: Union(OrderedCompletion?(Expression(Integer)),...)
fricas
limit(abs(x)/x,x=0,"left")

\label{eq4}- 1(4)
Type: Union(OrderedCompletion?(Expression(Integer)),...)

An approximation to signum

fricas
D(tanh(a*x),x)

\label{eq5}-{a \ {{\tanh \left({a \  x}\right)}^{2}}}+ a(5)
Type: Expression(Integer)
fricas
limit(%,a=%plusInfinity)

\label{eq6}\verb#"failed"#(6)
Type: Union("failed",...)

Patterns for derivatives

fricas
Abs:=operator('Abs)

\label{eq7}\hbox{\axiomType{Abs}\ }(7)
Type: BasicOperator?
fricas
D(abs(x),x)

\label{eq8}{abs \left({x}\right)}\over x(8)
Type: Expression(Integer)
fricas
signum:=operator('signum)

\label{eq9}signum(9)
Type: BasicOperator?
fricas
diracDelta:=operator('diracDelta)

\label{eq10}diracDelta(10)
Type: BasicOperator?
fricas
signum(x)

\label{eq11}signum \left({x}\right)(11)
Type: Expression(Integer)
fricas
D(signum(x),[x,x])

\label{eq12}{signum^{\prime \prime}}\left({x}\right)(12)
Type: Expression(Integer)
fricas
diff1:=rule
  signum(x) == Abs(x)/x
  D(Abs(x),x) == signum(x) + 2*x*diracDelta(x)
  D(signum(x),x) == 2*diracDelta(x)

\label{eq13}\begin{array}{@{}l}
\displaystyle
\left\{{= = \left({{signum \left({x}\right)}, \:{{\hbox{\axiomType{Abs}\ } \left({x}\right)}\over x}}\right)}, \: \right.
\
\
\displaystyle
\left.{= = \left({{{\hbox{\axiomType{Abs}\ }^{\prime}}\left({x}\right)}, \:{{signum \left({x}\right)}+{2 \  x \ {diracDelta \left({x}\right)}}}}\right)}, \: \right.
\
\
\displaystyle
\left.{= = \left({{{signum^{\prime}}\left({x}\right)}, \:{2 \ {diracDelta \left({x}\right)}}}\right)}\right\} 
(13)
Type: Ruleset(Integer,Integer,Expression(Integer))
fricas
diff(x,y)==diff1 D(x,y)
Type: Void
fricas
diff(Abs(x),x)
fricas
Compiling function diff with type (Expression(Integer), Variable(x))
       -> Expression(Integer)

\label{eq14}{{2 \ {{x}^{2}}\ {diracDelta \left({x}\right)}}+{\hbox{\axiomType{Abs}\ } \left({x}\right)}}\over x(14)
Type: Expression(Integer)
fricas
diff(Abs(x)/x,x)

\label{eq15}2 \ {diracDelta \left({x}\right)}(15)
Type: Expression(Integer)

Adding the singular part of the derivative

fricas
diff(f,x) == D(f,x)+(limit(f,x=0,"right")-limit(f,x=0,"left"))::EXPR(INT)*diracDelta(x)
Compiled code for diff has been cleared. 1 old definition(s) deleted for function or rule diff
Type: Void
fricas
diff(abs(x),x)
There are 9 exposed and 6 unexposed library operations named - having 2 argument(s) but none was determined to be applicable. Use HyperDoc Browse, or issue )display op - to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation. Cannot find a definition or applicable library operation named - with argument type(s) Union(OrderedCompletion(Expression(Integer)),"failed") Union(OrderedCompletion(Expression(Integer)),"failed")
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need. FriCAS will attempt to step through and interpret the code.

\label{eq16}{abs \left({x}\right)}\over x(16)
Type: Expression(Integer)
fricas
diff(%,x)

\label{eq17}2 \ {diracDelta \left({x}\right)}(17)
Type: Expression(Integer)
fricas
signum(x)==abs(x)/x
Type: Void
fricas
diff(signum(x),x)
fricas
Compiling function signum with type Variable(x) -> Expression(
      Integer)

\label{eq18}2 \ {diracDelta \left({x}\right)}(18)
Type: Expression(Integer)
fricas
integrate(signum(x),x)

\label{eq19}\int^{
\displaystyle
x}{{{abs \left({\%A}\right)}\over \%A}\ {d \%A}}(19)
Type: Union(Expression(Integer),...)

Heaviside

fricas
H(x)==(abs(x)+x)/2/x
Type: Void
fricas
H(-0.3),H(0.3)
fricas
Compiling function H with type Float -> Float

\label{eq20}\left[{0.0}, \:{1.0}\right](20)
Type: Tuple(Float)
fricas
diff(H(x),x)
fricas
Compiling function H with type Variable(x) -> Expression(Integer)

\label{eq21}diracDelta \left({x}\right)(21)
Type: Expression(Integer)

abs and sqrt

fricas
-- for x real
real:=operator('real)

\label{eq22}real(22)
Type: BasicOperator?
fricas
abs(real x)=sqrt(real(x)^2)

\label{eq23}{abs \left({real \left({x}\right)}\right)}={\sqrt{{real \left({x}\right)}^{2}}}(23)
Type: Equation(Expression(Integer))
fricas
-- OK
D(sqrt(x^2),x)

\label{eq24}x \over{\sqrt{{x}^{2}}}(24)
Type: Expression(Integer)
fricas
integrate(%,x)

\label{eq25}\sqrt{{x}^{2}}(25)
Type: Union(Expression(Integer),...)
fricas
-- Wrong
integrate(sqrt(x^2),x)

\label{eq26}{{x}^{2}}\over 2(26)
Type: Union(Expression(Integer),...)
fricas
D(%,x)

\label{eq27}x(27)
Type: Expression(Integer)
fricas
-- Expected
x*sqrt(x^2)/2

\label{eq28}{x \ {\sqrt{{x}^{2}}}}\over 2(28)
Type: Expression(Integer)
fricas
D(%,x)

\label{eq29}{{x}^{2}}\over{\sqrt{{x}^{2}}}(29)
Type: Expression(Integer)

fricas
integrate(sqrt(x^2),x=-2..2,"noPole")

\label{eq30}0(30)
Type: Union(f1: OrderedCompletion?(Expression(Integer)),...)
fricas
integrate(x,x=-2..2)

\label{eq31}0(31)
Type: Union(f1: OrderedCompletion?(Expression(Integer)),...)
fricas
integrate(abs(x),x=-2..2,"noPole")

\label{eq32}\verb#"failed"#(32)
Type: Union(fail: failed,...)

Solving differential equations, e.g. L f(x)=c(x)

fricas
-- differential Operator
L(f)==D(f,[x,x])
Type: Void
fricas
-- Green function
g(x)==abs(x)/2
Type: Void
fricas
-- pulse
c(x)==H(x+1/2)-H(x-1/2)
Type: Void
fricas
c(x)
fricas
Compiling function H with type Polynomial(Fraction(Integer)) -> 
      Expression(Integer)
fricas
Compiling function c with type Variable(x) -> Expression(Integer)

\label{eq33}{{{\left({2 \  x}- 1 \right)}\ {abs \left({{{2 \  x}+ 1}\over 2}\right)}}+{{\left(-{2 \  x}- 1 \right)}\ {abs \left({{{2 \  x}- 1}\over 2}\right)}}}\over{{4 \ {{x}^{2}}}- 1}(33)
Type: Expression(Integer)
fricas
-- convolution
integrand:=c(x-y)*g(y)
fricas
Compiling function c with type Polynomial(Integer) -> Expression(
      Integer)
fricas
Compiling function g with type Variable(y) -> Expression(Integer)

\label{eq34}{\left({\left({
\begin{array}{@{}l}
\displaystyle
{{\left({2 \  y}-{2 \  x}- 1 \right)}\ {abs \left({{{2 \  y}-{2 \  x}+ 1}\over 2}\right)}}+ 
\
\
\displaystyle
{{\left(-{2 \  y}+{2 \  x}- 1 \right)}\ {abs \left({{{2 \  y}-{2 \  x}- 1}\over 2}\right)}}
(34)
Type: Expression(Integer)
fricas
conv:=integrate(integrand,y=%minusInfinity..%plusInfinity)

\label{eq35}\verb#"potentialPole"#(35)
Type: Union(pole: potentialPole,...)
fricas
conv:=integrate(integrand,y=%minusInfinity..%plusInfinity,"noPole")

\label{eq36}\verb#"failed"#(36)
Type: Union(fail: failed,...)
fricas
conv:=integrate(integrand,y)

\label{eq37}\int^{
\displaystyle
y}{{{{{\left({2 \  x}-{2 \  \%A}- 1 \right)}\ {abs \left({\%A}\right)}\ {abs \left({{{2 \  x}-{2 \  \%A}+ 1}\over 2}\right)}}+{{\left(-{2 \  x}+{2 \  \%A}- 1 \right)}\ {abs \left({\%A}\right)}\ {abs \left({{{2 \  x}-{2 \  \%A}- 1}\over 2}\right)}}}\over{{8 \ {{x}^{2}}}-{{16}\  \%A \  x}+{8 \ {{\%A}^{2}}}- 2}}\ {d \%A}}(37)
Type: Union(Expression(Integer),...)
fricas
-- expected result
conv:=1/2*x^2*H(x+1/2)-1/2*x+1/2*x*H(x+1/2)+1/8*H(x+1/2)-1/2*x^2*H(x-1/2)+1/2*x*H(x-1/2)-1/8*H(x-1/2)

\label{eq38}{{{\left({2 \  x}+ 1 \right)}\ {abs \left({{{2 \  x}+ 1}\over 2}\right)}}+{{\left(-{2 \  x}+ 1 \right)}\ {abs \left({{{2 \  x}- 1}\over 2}\right)}}}\over 8(38)
Type: Expression(Integer)
fricas
-- ramp
diff(conv,x)

\label{eq39}{{abs \left({{{2 \  x}+ 1}\over 2}\right)}-{abs \left({{{2 \  x}- 1}\over 2}\right)}}\over 2(39)
Type: Expression(Integer)
fricas
test(L conv = c(x))
fricas
Compiling function L with type Expression(Integer) -> Expression(
      Integer)

\label{eq40} \mbox{\rm true} (40)
Type: Boolean

fricas
gnuDraw(H(x), x=-2..2, "SandBoxSignum1.dat")
fricas
Compiling function %R with type DoubleFloat -> DoubleFloat
Type: Void
fricas
gnuDraw(c(x), x=-2..2, "SandBoxSignum2.dat")
fricas
Compiling function %S with type DoubleFloat -> DoubleFloat
Type: Void
fricas
gnuDraw(conv, x=-3..3, "SandBoxSignum3.dat")
fricas
Compiling function %T with type DoubleFloat -> DoubleFloat
Type: Void

[terminal=pslatex,scale=1.3]
set yrange [0:2]
load "SandBoxSignum3.dat"




  Subject:   Be Bold !!
  ( 14 subscribers )  
Please rate this page: