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

# Edit detail for SandBoxSignum revision 13 of 13

 1 2 3 4 5 6 7 8 9 10 11 12 13 Editor: test1 Time: 2015/06/01 19:41:13 GMT+0 Note:

removed:
-)lib GDRAW


## Ref.

Derivative of abs

fricas
s1:=D(abs(x),x)
 (1)
Type: Expression(Integer)
fricas
D(s1,x)
 (2)
Type: Expression(Integer)
fricas
limit(abs(x)/x,x=0,"right")
 (3)
Type: Union(OrderedCompletion?(Expression(Integer)),...)
fricas
limit(abs(x)/x,x=0,"left")
 (4)
Type: Union(OrderedCompletion?(Expression(Integer)),...)

An approximation to signum

fricas
D(tanh(a*x),x)
 (5)
Type: Expression(Integer)
fricas
limit(%,a=%plusInfinity)
 (6)
Type: Union("failed",...)

Patterns for derivatives

fricas
Abs:=operator('Abs)
 (7)
Type: BasicOperator?
fricas
D(abs(x),x)
 (8)
Type: Expression(Integer)
fricas
signum:=operator('signum)
 (9)
Type: BasicOperator?
fricas
diracDelta:=operator('diracDelta)
 (10)
Type: BasicOperator?
fricas
signum(x)
 (11)
Type: Expression(Integer)
fricas
D(signum(x),[x,x])
 (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)
 (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)
 (14)
Type: Expression(Integer)
fricas
diff(Abs(x)/x,x)
 (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 -
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.
 (16)
Type: Expression(Integer)
fricas
diff(%,x)
 (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)
 (18)
Type: Expression(Integer)
fricas
integrate(signum(x),x)
 (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
 (20)
Type: Tuple(Float)
fricas
diff(H(x),x)
fricas
Compiling function H with type Variable(x) -> Expression(Integer)
 (21)
Type: Expression(Integer)

abs and sqrt

fricas
-- for x real
real:=operator('real)
 (22)
Type: BasicOperator?
fricas
abs(real x)=sqrt(real(x)^2)
 (23)
Type: Equation(Expression(Integer))
fricas
-- OK
D(sqrt(x^2),x)
 (24)
Type: Expression(Integer)
fricas
integrate(%,x)
 (25)
Type: Union(Expression(Integer),...)
fricas
-- Wrong
integrate(sqrt(x^2),x)
 (26)
Type: Union(Expression(Integer),...)
fricas
D(%,x)
 (27)
Type: Expression(Integer)
fricas
-- Expected
x*sqrt(x^2)/2
 (28)
Type: Expression(Integer)
fricas
D(%,x)
 (29)
Type: Expression(Integer)

fricas
integrate(sqrt(x^2),x=-2..2,"noPole")
 (30)
Type: Union(f1: OrderedCompletion?(Expression(Integer)),...)
fricas
integrate(x,x=-2..2)
 (31)
Type: Union(f1: OrderedCompletion?(Expression(Integer)),...)
fricas
integrate(abs(x),x=-2..2,"noPole")
 (32)
Type: Union(fail: failed,...)

Solving differential equations, e.g.

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)
 (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)
 (34)
Type: Expression(Integer)
fricas
conv:=integrate(integrand,y=%minusInfinity..%plusInfinity)
 (35)
Type: Union(pole: potentialPole,...)
fricas
conv:=integrate(integrand,y=%minusInfinity..%plusInfinity,"noPole")
 (36)
Type: Union(fail: failed,...)
fricas
conv:=integrate(integrand,y)
 (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)
 (38)
Type: Expression(Integer)
fricas
-- ramp
diff(conv,x)
 (39)
Type: Expression(Integer)
fricas
test(L conv = c(x))
fricas
Compiling function L with type Expression(Integer) -> Expression(
Integer)
 (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