use rustygrad::Value;
const EPS: f64 = 0.0001;
#[test]
fn value_example() {
let a = Value::from(-4.0);
let b = Value::from(2.0);
let mut c = &a + &b;
let mut d = &a * &b + &b.pow(3.0);
c += &c + 1.0;
c += 1.0 + &c + (-&a);
d += &d * 2.0 + (&b + &a).relu();
d += 3.0 * &d + (&b - &a).relu();
let e = &c - &d;
let f = e.pow(2.0);
let mut g = &f / 2.0;
g += 10.0 / &f;
assert!((24.7041 - g.borrow().data).abs() < EPS);
g.backward();
assert!((138.8338 - a.borrow().grad).abs() < EPS);
assert!((645.5773 - b.borrow().grad).abs() < EPS);
}