Skip to content

Disappearing variables #391

@aquohn

Description

@aquohn

I'm trying to optimise an expression with 4 variables:

1/2 * sqrt((2/(t^2) + 1/(1-x)) * 2^(l - H))

with precondition

0 < t < 1 and 0 < x < 1 and l > 1 and H > 0

However, the final output is independent of x!
image

This was on my local install, with the following reproduce block:

herbie shell --seed 236171898 
(FPCore (t x l H)
  :name "1/2 * sqrt((2/(t^2) + 1/(1-x)) * 2^(l - H))"
  :precision binary64
  :pre (and (and (and (< 0.0 t 1.0) (< 0.0 x 1.0)) (> l 1.0)) (> H 0.0))
  (* (/ 1.0 2.0) (sqrt (* (+ (/ 2.0 (pow t 2.0)) (/ 1.0 (- 1.0 x))) (pow 2.0 (- l H))))))

x seems to disappear when Herbie Taylor expands around 0.

Running the online version gave me
image

With reproduce block

herbie shell --seed 1 
(FPCore (t x l H)
  :name "1/2 * sqrt((2/(t^2) + 1/(1-x)) * 2^(l - H))"
  :precision binary64
  :pre (and (and (and (< 0.0 t 1.0) (< 0.0 x 1.0)) (> l 1.0)) (> H 0.0))
  (* (/ 1.0 2.0) (sqrt (* (+ (/ 2.0 (pow t 2.0)) (/ 1.0 (- 1.0 x))) (pow 2.0 (- l H))))))

However, trying an equivalent version of the same expression on the online demo gives
image

x also disappears in the Taylor expansion step. The reproduce block is as follows.

herbie shell --seed 1 
(FPCore (t x l H)
  :name "1/2 * sqrt((2/(t^2) + 1/(1-x))) * sqrt(2^(l - H))"
  :precision binary64
  :pre (and (and (and (< 0.0 t 1.0) (< 0.0 x 1.0)) (> l 1.0)) (> H 0.0))
  (* (* (/ 1.0 2.0) (sqrt (+ (/ 2.0 (pow t 2.0)) (/ 1.0 (- 1.0 x))))) (sqrt (pow 2.0 (- l H)))))

I'm quite confused as to what's going on here; does it set x to 0 and then forget about it somehow during the Taylor expansion step?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions