Skip to content

Confusing result #25

Description

@alecjacobson

Love this paper :-) first time trying the code.

Here's my problem set up.
image

E = ½ ∫₀¹ ([x<a] - [x<t])² dx
∂E/∂t = t>a?+1:-1 = [0<t<1] - 2 [t<a]

I claim that ∂E/∂t = [0<t<1] - 2 [t < α] → if t is smaller (bigger) than α then I grow my energy by making it more smaller (bigger) than α. This is confirmed with F.D.

When I try this in Teg, I wrote:

from teg import TegVar, Var, Teg, IfElse
from teg.derivs import FwdDeriv
from teg.eval.numpy_eval import evaluate
x, a, t = TegVar('x'), Var('a', 0.5), Var('t', 0.25)
expr = 0.5*Teg(0, 
               1,
               (IfElse(x<t,1,0) - IfElse(x<a,1,0))**2,
               x)
deriv_expr = FwdDeriv(expr, [(t, 1)])
print(evaluate(deriv_expr))

x, a, t = TegVar('x'), Var('a', 0.5), Var('t', 0.75)
expr = 0.5*Teg(0, 
               1,
               (IfElse(x<t,1,0) - IfElse(x<a,1,0))**2,
               x)
deriv_expr = FwdDeriv(expr, [(t, 1)])
print(evaluate(deriv_expr))

Which prints

-1.0
0

I'm confused by the 0 which I expected to be 1.0

cc @squidrice21

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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