Commit 9726642b authored by Anastasiia's avatar Anastasiia

associativity is broken

parent f7b22796
......@@ -266,14 +266,14 @@ object DynamicPhase extends DaisyPhase {
case Variable(id) => valMap(id)
case RealLiteral(r) => r.toDouble
case Plus(x, y) =>
reporter.warning(s"x + y = $x + $y")
reporter.debug(s"x + y = $x + $y")
val tmp = eval(x) + eval(y)
reporter.warning(s"=$tmp")
reporter.debug(s"=$tmp")
tmp
case Minus(x, y) => eval(x) - eval(y)
case Times(x, y) => reporter.warning(s"x * y = $x * $y")
case Times(x, y) => reporter.debug(s"x * y = $x * $y")
val tmp = eval(x) * eval(y)
reporter.warning(s"=$tmp")
reporter.debug(s"=$tmp")
tmp
case Division(x, y) => eval(x) / eval(y)
case Pow(x, y) => math.pow( eval(x), eval(y))
......
......@@ -3,23 +3,35 @@ import Real._
object TimesPlusReal {
def sumplus(u: Real): Real = {
require(-11.633685649025693 <= u && u <= -11.633685649025693) // 100
// maxAbsError: 2.926454093647371e-17 maxRelError: 4.6812116338827325e-12
0.0447 * u + 0.483292 + 0.03674
// def sumPlus2terms(u: Real): Real = {
// require(-11.633685649025693 <= u && u <= -11.633685649025693) // 100
// // maxAbsError: 2.926454093647371e-17 maxRelError: 4.6812116338827325e-12
// 0.0447 * u + 0.483292 + 0.03674
//
// }
//
// def plusSum(u: Real): Real ={
// require(-11.633685649025693 <= u && u <= -11.633685649025693)
// // maxAbsError: 7.783679826382432e-17 maxRelError: 1.2450922307913817e-11
// 0.483292 + 0.03674 + 0.0447 * u
// }
//
// def sumPlus1term(u: Real): Real ={
// require(-11.633685649025693 <= u && u <= -11.633685649025693)
// // maxAbsError: 7.783679826382432e-17 maxRelError: 1.2450922307913817e-11
// 0.0447 * u + 0.520032
// }
def plusSum2TermsPure(u: Real, x: Real): Real = {
require(-11.633685649025693 <= u && u <= -11.633685649025693
&& 1<= x && x<= 1)
0.483292 + 0.03674 * x + 0.0447 * u
}
def plussum(u: Real): Real ={
require(-11.633685649025693 <= u && u <= -11.633685649025693)
// maxAbsError: 7.783679826382432e-17 maxRelError: 1.2450922307913817e-11
0.483292 + 0.03674 + 0.0447 * u
}
def thirdway(u: Real): Real ={
require(-11.633685649025693 <= u && u <= -11.633685649025693)
// maxAbsError: 7.783679826382432e-17 maxRelError: 1.2450922307913817e-11
0.0447 * u + 0.520032
def plusSum2TermsParenthesis(u: Real, x: Real): Real = {
require(-11.633685649025693 <= u && u <= -11.633685649025693
&& 1<= x && x<= 1)
0.483292 + (0.03674 * x + 0.0447 * u)
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment