JuliaSymbolics / SymbolicUtils.jl

Symbolic expressions, rewriting and simplification
https://docs.sciml.ai/SymbolicUtils/stable/
Other
523 stars 99 forks source link

Add `Symbolic` number constructor and conversion #602

Closed bowenszhu closed 2 weeks ago

bowenszhu commented 1 month ago

This pull request adds a constructor and a conversion function for Symbolic objects representing numbers.

Key changes:

These changes provide a more convenient and flexible way to create and work with symbolic representations of numbers, and hide the internal Symbolic subtype system from external users.

github-actions[bot] commented 1 month ago

Benchmark Results

master dfec04ec7c5196... master/dfec04ec7c5196...
overhead/acrule/a+2 0.713 ± 0.016 μs 0.735 ± 0.017 μs 0.97
overhead/acrule/a+2+b 0.691 ± 0.015 μs 0.71 ± 0.018 μs 0.974
overhead/acrule/a+b 0.26 ± 0.0091 μs 0.255 ± 0.013 μs 1.02
overhead/acrule/noop:Int 25.9 ± 0.059 ns 24.7 ± 0.92 ns 1.05
overhead/acrule/noop:Sym 0.0363 ± 0.0056 μs 0.0421 ± 0.006 μs 0.863
overhead/rule/noop:Int 0.044 ± 0.0012 μs 0.0438 ± 0.0014 μs 1
overhead/rule/noop:Sym 0.0546 ± 0.0024 μs 0.0542 ± 0.0022 μs 1.01
overhead/rule/noop:Term 0.0544 ± 0.0024 μs 0.0545 ± 0.0016 μs 0.997
overhead/ruleset/noop:Int 0.132 ± 0.0037 μs 0.132 ± 0.0045 μs 0.999
overhead/ruleset/noop:Sym 0.155 ± 0.0051 μs 0.154 ± 0.0033 μs 1.01
overhead/ruleset/noop:Term 3.8 ± 0.14 μs 3.77 ± 0.14 μs 1.01
overhead/simplify/noop:Int 0.141 ± 0.0031 μs 0.138 ± 0.0031 μs 1.02
overhead/simplify/noop:Sym 0.154 ± 0.0029 μs 0.152 ± 0.0025 μs 1.01
overhead/simplify/noop:Term 0.038 ± 0.0019 ms 0.0377 ± 0.0023 ms 1.01
overhead/simplify/randterm (+, *):serial 0.117 ± 0.0034 s 0.119 ± 0.004 s 0.985
overhead/simplify/randterm (+, *):thread 0.0723 ± 0.021 s 0.0741 ± 0.024 s 0.975
overhead/simplify/randterm (/, *):serial 0.221 ± 0.005 ms 0.223 ± 0.0061 ms 0.987
overhead/simplify/randterm (/, *):thread 0.252 ± 0.0056 ms 0.252 ± 0.0069 ms 1
overhead/substitute/a 0.0609 ± 0.0014 ms 0.0603 ± 0.0014 ms 1.01
overhead/substitute/a,b 0.0534 ± 0.0014 ms 0.052 ± 0.0013 ms 1.03
overhead/substitute/a,b,c 17.5 ± 0.57 μs 16.3 ± 0.61 μs 1.07
polyform/easy_iszero 0.0337 ± 0.0016 ms 0.0341 ± 0.0017 ms 0.989
polyform/isone 3.1 ± 0.01 ns 2.79 ± 0.01 ns 1.11
polyform/iszero 1.79 ± 0.03 ms 1.8 ± 0.032 ms 0.993
polyform/simplify_fractions 2.41 ± 0.038 ms 2.4 ± 0.04 ms 1
time_to_load 4.52 ± 0.014 s 4.53 ± 0.029 s 0.999

Benchmark Plots

A plot of the benchmark results have been uploaded as an artifact to the workflow run for this PR. Go to "Actions"->"Benchmark a pull request"->[the most recent run]->"Artifacts" (at the bottom).

bowenszhu commented 2 weeks ago

I'm closing this pull request because we've decided to implement the feature using a different approach that will be more efficient and scalable. I'll create a new pull request for this alternative solution soon.