BeginComment:
This program demonstrates the math library.

Copyright © 2016 Richard Lesh.  All rights reserved.
EndComment

#Pragma: UseUnicode

BeginProgram: Math1

BeginMain:
	ScalarDecl: const <double> a = pi() / 6
	ScalarDecl: const <double> b = pi() / 4
	ScalarDecl: const <double> c = -a * 2
	ScalarDecl: const <double> d = -b * 2
	ScalarDecl: const <double> e = e()

	PrintLine: format("pi = {0:f}", pi())
	PrintLine: format("e = {0:f}", e())

	Comment: abs, floor, ceil, round, trunc, min, max
	PrintLine: format("abs({0:f}) = {1:f}", a, fabs(a))
	PrintLine: format("abs({0:f}) = {1:f}", c, fabs(c))
	PrintLine: format("floor({0:f}) = {1:f}", a, floor(a))
	PrintLine: format("floor({0:f}) = {1:f}", c, floor(c))
	PrintLine: format("ceil({0:f}) = {1:f}", a, ceil(a))
	PrintLine: format("ceil({0:f}) = {1:f}", c, ceil(c))
	PrintLine: format("round({0:f}) = {1:f}", a, round(a))
	PrintLine: format("round({0:f}) = {1:f}", c, round(c))
	PrintLine: format("trunc({0:f}) = {1:f}", a, trunc(a))
	PrintLine: format("trunc({0:f}) = {1:f}", c, trunc(c))
	PrintLine: format("min({0:f}, {1:f}) = {2:f}", a, c, fmin(a,c))
	PrintLine: format("max({0:f}, {1:f}) = {2:f}", a, c, fmax(a,c))

	Comment: sin, cos, tan, atan, atan2, acos, asin
	PrintLine: format("sin({0:f}) = {1:f}", a, sin(a))
	PrintLine: format("sin({0:f}) = {1:f}", b, sin(b))
	PrintLine: format("sin({0:f}) = {1:f}", c, sin(c))
	PrintLine: format("sin({0:f}) = {1:f}", d, sin(d))
	PrintLine: format("cos({0:f}) = {1:f}", a, cos(a))
	PrintLine: format("cos({0:f}) = {1:f}", b, cos(b))
	PrintLine: format("cos({0:f}) = {1:f}", c, cos(c))
	PrintLine: format("cos({0:f}) = {1:f}", d, cos(d))
	PrintLine: format("tan({0:f}) = {1:f}", a, tan(a))
	PrintLine: format("tan({0:f}) = {1:f}", b, tan(b))
	PrintLine: format("tan({0:f}) = {1:f}", c, tan(c))
	PrintLine: format("asin({0:f}) = {1:f}", sin(a), asin(sin(a)))
	PrintLine: format("asin({0:f}) = {1:f}", sin(b), asin(sin(b)))
	PrintLine: format("asin({0:f}) = {1:f}", sin(c), asin(sin(c)))
	PrintLine: format("asin({0:f}) = {1:f}", sin(d), asin(sin(d)))
	PrintLine: format("acos({0:f}) = {1:f}", cos(a), acos(cos(a)))
	PrintLine: format("acos({0:f}) = {1:f}", cos(b), acos(cos(b)))
	PrintLine: format("acos({0:f}) = {1:f}", cos(c), acos(cos(c)))
	PrintLine: format("acos({0:f}) = {1:f}", cos(d), acos(cos(d)))
	PrintLine: format("atan({0:f}) = {1:f}", tan(a), atan(tan(a)))
	PrintLine: format("atan({0:f}) = {1:f}", tan(b), atan(tan(b)))
	PrintLine: format("atan({0:f}) = {1:f}", tan(c), atan(tan(c)))
	Comment: 45 degrees
	PrintLine: format("atan2({0:f}, {1:f}) = {2:f}", 1.0, 1.0, atan2(1.0,1.0))
	Comment: 30 degrees
	PrintLine: format("atan2({0:f}, {1:f}) = {2:f}", 1.0, sqrt(3.0), atan2(1.0,sqrt(3.0)))

	Comment: sinh, cosh, tanh, atanh, acosh, asinh
	PrintLine: format("sinh({0:f}) = {1:f}", a, sinh(a))
	PrintLine: format("sinh({0:f}) = {1:f}", b, sinh(b))
	PrintLine: format("sinh({0:f}) = {1:f}", c, sinh(c))
	PrintLine: format("sinh({0:f}) = {1:f}", d, sinh(d))
	PrintLine: format("cosh({0:f}) = {1:f}", a, cosh(a))
	PrintLine: format("cosh({0:f}) = {1:f}", b, cosh(b))
	PrintLine: format("cosh({0:f}) = {1:f}", c, cosh(c))
	PrintLine: format("cosh({0:f}) = {1:f}", d, cosh(d))
	PrintLine: format("tanh({0:f}) = {1:f}", a, tanh(a))
	PrintLine: format("tanh({0:f}) = {1:f}", b, tanh(b))
	PrintLine: format("tanh({0:f}) = {1:f}", c, tanh(c))
	PrintLine: format("tanh({0:f}) = {1:f}", d, tanh(d))
	PrintLine: format("asinh({0:f}) = {1:f}", sinh(a), asinh(sinh(a)))
	PrintLine: format("asinh({0:f}) = {1:f}", sinh(b), asinh(sinh(b)))
	PrintLine: format("asinh({0:f}) = {1:f}", sinh(c), asinh(sinh(c)))
	PrintLine: format("asinh({0:f}) = {1:f}", sinh(d), asinh(sinh(d)))
	PrintLine: format("acosh({0:f}) = {1:f}", cosh(a), acosh(cosh(a)))
	PrintLine: format("acosh({0:f}) = {1:f}", cosh(b), acosh(cosh(b)))
	PrintLine: format("acosh({0:f}) = {1:f}", cosh(c), acosh(cosh(c)))
	PrintLine: format("acosh({0:f}) = {1:f}", cosh(d), acosh(cosh(d)))
	PrintLine: format("atanh({0:f}) = {1:f}", tanh(a), atanh(tanh(a)))
	PrintLine: format("atanh({0:f}) = {1:f}", tanh(b), atanh(tanh(b)))
	PrintLine: format("atanh({0:f}) = {1:f}", tanh(c), atanh(tanh(c)))
	PrintLine: format("atanh({0:f}) = {1:f}", tanh(d), atanh(tanh(d)))

	Comment: log, log10, exp, pow, sqrt
	PrintLine: format("log({0:f}) = {1:f}", a, log(a))
	PrintLine: format("log({0:f}) = {1:f}", b, log(b))
	PrintLine: format("log({0:f}) = {1:f}", -c, log(-c))
	PrintLine: format("log({0:f}) = {1:f}", -d, log(-d))
	PrintLine: format("log({0:f}) = {1:f}", e, log(e))
	PrintLine: format("log10({0:f}) = {1:f}", a, log10(a))
	PrintLine: format("log10({0:f}) = {1:f}", b, log10(b))
	PrintLine: format("log10({0:f}) = {1:f}", -c, log10(-c))
	PrintLine: format("log10({0:f}) = {1:f}", -d, log10(-d))
	PrintLine: format("log10({0:f}) = {1:f}", e, log10(e))
	PrintLine: format("exp({0:f}) = {1:f}", 0.5, exp(0.5))
	PrintLine: format("exp({0:f}) = {1:f}", 1.0, exp(1.0))
	PrintLine: format("exp({0:f}) = {1:f}", 2.0, exp(2.0))
	PrintLine: format("pow({0:f}, {1:f}) = {2:f}", 10.0, 0.5, pow(10.0, 0.5))
	PrintLine: format("pow({0:f}, {1:f}) = {2:f}", 10.0, 1.0, pow(10.0, 1.0))
	PrintLine: format("pow({0:f}, {1:f}) = {2:f}", 10.0, 2.0, pow(10.0, 2.0))
	PrintLine: format("sqrt({0:f}) = {1:f}", 0.5, sqrt(0.5))
	PrintLine: format("sqrt({0:f}) = {1:f}", 2.0, sqrt(2.0))
	PrintLine: format("sqrt({0:f}) = {1:f}", 10.0, sqrt(10.0))

	Comment: random numbers
	PrintLine: format("random() = {0:f}", random())
	PrintLine: format("random() = {0:f}", random())
	PrintLine: format("random() = {0:f}", random())
EndMain
EndProgram
