Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More test coverage for coeff #1133

Merged
merged 1 commit into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/src/manual/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ du
Note that what has been done here is that the imperative Julia code
for the function `lorenz` has been transformed into a declarative
symbolic graph. Importantly, the code of `lorenz` is transformed
into an expression consisting only of primitive registered fucntions,
into an expression consisting only of primitive registered functions,
things like `*` and `-`, which come pre-registered with Symbolics.jl
This then allows for symbolic manipulation of the expressions,
allowing things like simplification and operation
Expand All @@ -66,7 +66,7 @@ to C code, are used, then the tracing process will error.

However, we note that symbolic tracing by definition does not
guarantee that the exact choices. The symbolic expressions
may re-distribute the arithmatic, simplify out expressions, or
may re-distribute the arithmetic, simplify out expressions, or
do other modifications. Thus if this function is function is
sensitive to numerical details in its calculation, one would not
want to trace the function and thus would instead register it
Expand Down Expand Up @@ -187,4 +187,4 @@ The derivative is defined similarly to the macro case:
function Symbolics.derivative(interp::AbstractInterpolation, args::NTuple{1, Any}, ::Val{1})
Symbolics.unwrap(derivative(interp, Symbolics.wrap(args[1])))
end
```
```
5 changes: 5 additions & 0 deletions test/coeff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import Symbolics: coeff
@test isequal(coeff(2a, x), 0)
@test isequal(coeff(a*x, x), a)
@test isequal(coeff(2x*a, x), 2a)
# Symbolic powers:
@test isequal(coeff(a*x^b, x^b), a)
@test isequal(coeff(a*x^(b+1), x^(b+1)), a)
# Irrational powers:
@test isequal(coeff(a*x^sqrt(2), x^sqrt(2)), a)

@test isequal(coeff(a + x, x), 1)
@test isequal(coeff(2(a + x), x), 2)
Expand Down
Loading