e not defined for sqrt()
harrybooth opened this issue · 6 comments
Hi
@var x y a b
F = System([sqrt(x^2 - a), x * y - a + b]; variables=[x,y], parameters =[a,b])
solve(F, target_parameters=[2, 5])
produces the error
UndefVarError: e not defined
I believe it is the sqrt() which is causing the issue.
- we can only solve polynomial system, so the square root is not allowed
- Your system has the same zeros if you just omit the sqrt :)
Hi,
Thanks for the reply @saschatimme .
Regarding 1) - I thought in this issue: #498 it was stated that there was support for sqrt
on main?
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 ofexp
andlog
since you can rewritex^a
asexp(a * log(x))
and reuse theexp
andlog
primitives. Here are the recursive relationships forexp
andlog
(p. 306)If somebody is interested in giving this a shot I can also provide more guidance.
and re 2) - Yes true, although I was just providing a minimal example to show the error. My actual system is more complex..
Regarding 1) - I thought in this issue: #498 it was stated that there was support for sqrt on main?
Mhm maybe there is a bug then. I will look more into this over the weekend. As for whether you can use sqrt or not: Our math only works when sqrt
is used for parameters. So no variables inside sqrt
allowed.
Suppose I can rearrange my system so that the square roots are on one side of the equation, is it valid in general to square both sides and solve the new system using homotopy continuation methods? I really need to solve a system where the variables sit inside the square root and this is the only way I can think of, but I'm not sure if its valid...
I think this should be a valid way to rewrite the system.
A more general way of rewriting a system with a sqrt is the following pattern:
Starting from
f(x) + sqrt(g(x)) = 0
add one additional variable y
and write the system
f(x) + a = 0
a^2 = g(x)
Your approach as well as mine both increases the number of solution but this is unavoidable.
I wrote some time ago a paper where the true problem also had a sqrt in it's formulation. Maybe the general techniques used there can be useful for you https://arxiv.org/pdf/2009.13408.pdf
Otherwise, if you can share more about your problem (here or via email) with me or @PBrdng, then we can maybe give more concrete advice. We are both always happy to learn about applications of HC :)
Sure, would be great to discuss with you. I will send you an email to sascha@timme.xyz ?