JuliaHomotopyContinuation / HomotopyContinuation.jl

A Julia package for solving systems of polynomials via homotopy continuation.
https://www.JuliaHomotopyContinuation.org
MIT License
185 stars 30 forks source link

Fractional powers not supported by ModelKit #498

Open jkosata opened 2 years ago

jkosata commented 2 years ago
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.

PBrdng commented 2 years ago

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

oameye commented 1 year ago

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)
saschatimme commented 1 year ago

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.