Fractional powers not supported by ModelKit
Opened this issue · 3 comments
julia> @var a
julia> a^(1/2)
ERROR: ^ not defined for Expression
Fractional powers are sometimes desirable for parameters in parameter homotopy.
One can fix ^
in src/model_kit/symengine.jl
, but the fractional powers then still trigger AssertionError: class(n) == :Integer
when solving.
It's true: fractional powers are not supported by model_kit
.
Can you send a short example?
Could it be an option to define a custom homotopy? See here:
HomotopyContinuation.jl/src/model_kit/abstract_system_homotopy.jl
Lines 87 to 103 in d40ec60
Could integration with Symbolics.jl, i.e., removal of the symengine dependency in favour of Symbolics.jl as suggested in #456, solve this issue?
using Symbolics
@variables a
a^(1/2)
No this is unfortunately not so straightforward. We internally have a fairly complex system for the evaluation of systems where the input are taylor polynomials. We need this for the predictor step to compute higher order derivatives of x(t)
. See Chapter 13 of Evaluating Derivatives from Griewank and Walther.
On the main branch we have already support for sqrt
but not for general real powers. For this we need to first implement the taylor polynomial expansions of exp
and log
since you can rewrite x^a
as exp(a * log(x))
and reuse the exp
and log
primitives. Here are the recursive relationships for exp
and log
(p. 306)
If somebody is interested in giving this a shot I can also provide more guidance.