Created
April 25, 2015 01:36
-
-
Save Gabriella439/011424bec6d839d98b0b to your computer and use it in GitHub Desktop.
Good game
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Numeric.AD | |
assert = print | |
eval = id | |
main = do | |
let a x = 2 * x^2 + 3 | |
let b = eval a 1 | |
assert (b == 5) -- Prints `True` | |
let d = diff a | |
assert (eval d 1 == 4) -- Prints `True` | |
-- Of course, this is silly, we can just get rid of `eval` and `assert` | |
-- completely ... | |
print ( a 1) -- Prints `5` | |
print (diff a 1) -- Prints `4` | |
-- Your symbolic integration is undefined: you need to specify integration | |
-- bounds |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
say poly = 3x^4 + 5x^3+2x^2+7x+8
then encode poly as 2 vectors
poly = (3 5 2 7 1) (4 3 2 1 0)
diff would just be dot product
( 3_4 5_3 2_2 7_1 1) (3 2 1 0 0)
int would be similar too..