jazzmuesli / expcomp

Explainable computations

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Explainable computations in scala.

Example 1:

pi=3.141592653589793
e=2.718281828459045
pie=(5.859874482048838=3.141592653589793 + 2.718281828459045)
roundedPie=(5.86=(5.859874482048838=3.141592653589793 + 2.718281828459045) round 3.0)

Example 2:

EURUSD=Rate(bid=1.2333, offer=1.2338)
AUDUSD=Rate(bid=(0.7833=0.7843 - (0.001=0.002 * 0.5)), offer=(0.7853=0.7843 + (0.001=0.002 * 0.5)))=SpreadedRate(mid=0.7843, spread=0.002)
EURAUD=Rate(bid=(1.5705=(1.5704826181077296=1.2333 / (0.7853=0.7843 + (0.001=0.002 * 0.5))) round 4.0), offer=(1.5751=(1.575130856632197=1.2338 / (0.7833=0.7843 - (0.001=0.002 * 0.5))) round 4.0))

Example 3:

EURUSD_SPOT=Rate
	(bid=1.2333, offer=1.2338)
AUDUSD_SPOT=Rate
	(bid=
		(0.7833=0.7843 - 
			(0.001=0.002 * 0.5)), offer=
		(0.7853=0.7843 + 
			(0.001=0.002 * 0.5)))=SpreadedRate
	(mid=0.7843, spread=0.002)
EURUSD_1M=Rate
	(bid=0.0013, offer=0.0017)
AUDUSD_1M=Rate
	(bid=0.0023, offer=0.0029)
EURAUD points with spread widened by 4.9E-4=Rate
	(bid=
		(-0.00437=
			(-0.004373900777102596=
				(-0.003288229010148802=
					(-0.006576458020297604=
						(-0.004128900777102595=
							(1.566353717330627=
								(1.2346000000000001=1.2333 + 0.0013) / 
								(0.7882=
									(0.7853=0.7843 + 
										(0.001=0.002 * 0.5)) + 0.0029)) - 
							(1.5704826181077296=1.2333 / 
								(0.7853=0.7843 + 
									(0.001=0.002 * 0.5)))) + 
						(-0.0024475572431950088=
							(1.572683299389002=
								(1.2355=1.2338 + 0.0017) / 
								(0.7856=
									(0.7833=0.7843 - 
										(0.001=0.002 * 0.5)) + 0.0023)) - 
							(1.575130856632197=1.2338 / 
								(0.7833=0.7843 - 
									(0.001=0.002 * 0.5))))) * 0.5) - 
				(0.0010856717669537933=
					(0.0021713435339075866=
						(0.0016813435339075866=
							(-0.0024475572431950088=
								(1.572683299389002=
									(1.2355=1.2338 + 0.0017) / 
									(0.7856=
										(0.7833=0.7843 - 
											(0.001=0.002 * 0.5)) + 0.0023)) - 
								(1.575130856632197=1.2338 / 
									(0.7833=0.7843 - 
										(0.001=0.002 * 0.5)))) - 
							(-0.004128900777102595=
								(1.566353717330627=
									(1.2346000000000001=1.2333 + 0.0013) / 
									(0.7882=
										(0.7853=0.7843 + 
											(0.001=0.002 * 0.5)) + 0.0029)) - 
								(1.5704826181077296=1.2333 / 
									(0.7853=0.7843 + 
										(0.001=0.002 * 0.5))))) + 4.9E-4) * 0.5)) round 5.0), offer=
		(-0.0022=
			(-0.002202557243195009=
				(-0.003288229010148802=
					(-0.006576458020297604=
						(-0.004128900777102595=
							(1.566353717330627=
								(1.2346000000000001=1.2333 + 0.0013) / 
								(0.7882=
									(0.7853=0.7843 + 
										(0.001=0.002 * 0.5)) + 0.0029)) - 
							(1.5704826181077296=1.2333 / 
								(0.7853=0.7843 + 
									(0.001=0.002 * 0.5)))) + 
						(-0.0024475572431950088=
							(1.572683299389002=
								(1.2355=1.2338 + 0.0017) / 
								(0.7856=
									(0.7833=0.7843 - 
										(0.001=0.002 * 0.5)) + 0.0023)) - 
							(1.575130856632197=1.2338 / 
								(0.7833=0.7843 - 
									(0.001=0.002 * 0.5))))) * 0.5) + 
				(0.0010856717669537933=
					(0.0021713435339075866=
						(0.0016813435339075866=
							(-0.0024475572431950088=
								(1.572683299389002=
									(1.2355=1.2338 + 0.0017) / 
									(0.7856=
										(0.7833=0.7843 - 
											(0.001=0.002 * 0.5)) + 0.0023)) - 
								(1.575130856632197=1.2338 / 
									(0.7833=0.7843 - 
										(0.001=0.002 * 0.5)))) - 
							(-0.004128900777102595=
								(1.566353717330627=
									(1.2346000000000001=1.2333 + 0.0013) / 
									(0.7882=
										(0.7853=0.7843 + 
											(0.001=0.002 * 0.5)) + 0.0029)) - 
								(1.5704826181077296=1.2333 / 
									(0.7853=0.7843 + 
										(0.001=0.002 * 0.5))))) + 4.9E-4) * 0.5)) round 5.0))

Disadvantages

As you can see in ExplainableComputationsTest::testPerformance, this approach is 15-60x slower than raw arithmetic operations on doubles.

Build Status

About

Explainable computations


Languages

Language:Scala 100.0%