在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:HarrisonGrodin/Simplify.jl开源软件地址:https://github.com/HarrisonGrodin/Simplify.jl开源编程语言:Julia 100.0%开源软件介绍:Simplify.jlSimplify.jl implements methods for symbolic algebraic simplification in the Julia language. ExamplesNormalization involves determining the unique normal form of an expression ("simplest" equivalent expression) through repeated application of rules. Simplify.jl will use its internal set of algebraic rules by default, which includes trigonometry, logarithms, differentiation (based on DiffRules.jl), and more. julia> @syms x y b θ;
julia> normalize(@term(1 / (sin(-θ) / cos(-θ))))
@term(1 / (-(sin(θ)) / cos(θ)))
julia> normalize(@term(log(b, 1 / (b^abs(x^2)))))
@term(log(b, 1 / b ^ abs(x ^ 2)))
julia> normalize(@term(diff(sin(2x) - log(x+y), x)))
@term(1 * -(inv(x + y) * (1 * diff(y, x) + 1 * one(x))) + 1 * cos(2x) * (2 * one(x) + x * 0))
julia> normalize(@term(!x & x | (y & (y | true))))
@term(!x & x | (y | true) & y)
julia> normalize(@term(y^(6 - 3log(x, x^2))))
@term(y ^ (-(6 * log(x, x)) + 6)) In many cases, it is useful to specify entirely custom rules by passing a Term Rewriting System as the second argument to julia> @syms f g h;
@vars x y;
julia> normalize(@term(f(x, f(y, y))), @term RULES [
f(x, x) => 1
f(x, 1) => x
])
@term(x)
julia> normalize(@term(f(g(f(1), h()))), Rules(
@term(f(x)) => @term(x),
@term(h()) => @term(3),
))
@term(g(1, 3))
julia> using Simplify: EvalRule
julia> normalize(@term(f(g(f(1), h()))), Rules(
@term(f(x)) => @term(x),
@term(h()) => @term(3),
EvalRule(g, (a, b) -> 2a + b)
))
@term(5) Variables may contain information about their domain, which may result in more specific normalizations. julia> using SpecialSets
julia> @syms x y z;
julia> ctx = [get_context(); Image(y, GreaterThan(3)); Image(z, Even ∩ LessThan(0))];
julia> with_context(ctx) do
normalize(@term(abs(x)))
end
@term(abs(x))
julia> with_context(ctx) do
normalize(@term(abs(y)))
end
@term(y)
julia> with_context(ctx) do
normalize(@term(abs(z)))
end
@term(-z) julia> ctx = [get_context(); Image(x, TypeSet(Int)); Image(y, TypeSet(Int))];
julia> with_context(ctx) do
normalize(@term(diff(sin(2x) - log(x + y), x)))
end
@term(cos(2x) * 2 + -(inv(x + y) * (diff(y, x) + 1))) Acknowledgements |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论