HomotopyContinuation.jl icon indicating copy to clipboard operation
HomotopyContinuation.jl copied to clipboard

Fractional powers not supported by ModelKit

Open jkosata opened this issue 3 years ago • 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.

jkosata avatar Dec 21 '21 10:12 jkosata

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: https://github.com/JuliaHomotopyContinuation/HomotopyContinuation.jl/blob/d40ec60f387e8144d7c36439af9e8a3c46efff8d/src/model_kit/abstract_system_homotopy.jl#L87-L103

PBrdng avatar Dec 28 '21 14:12 PBrdng

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)

oameye avatar Oct 18 '22 13:10 oameye

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)

Screenshot 2022-10-19 at 21 30 11

If somebody is interested in giving this a shot I can also provide more guidance.

saschatimme avatar Oct 19 '22 19:10 saschatimme