diff --git a/constantphase.cpp b/constantphase.cpp
index 5814e9bc9817f6acb18ea8e15cb46335ca331ad7..5e68df6cdc4caddef89ee9b4365ff0ab6f8d9471 100644
--- a/constantphase.cpp
+++ b/constantphase.cpp
@@ -1,6 +1,7 @@
 #include "constantphase.h"
 #include "strops.h"
 #include <cstdlib>
+#include <string>
 #define _USE_MATH_DEFINES
 #include <cmath>
 #include <cassert>
@@ -85,12 +86,13 @@ std::string Cpe::getCode(std::vector<std::string>& parameters)
 
 std::string Cpe::getTorchScript(std::vector<std::string>& parameters)
 {
+	std::string hpi = std::to_string(M_PI/2);
 	std::string firstParameter = getUniqueName() + "_0";
 	std::string secondParameter = getUniqueName() + "_1";
 	parameters.push_back(firstParameter);
 	parameters.push_back(secondParameter);
-	std::string real = "(1/(" + firstParameter + "*torch.pow(omegas,"+ secondParameter +")))*torch.cos((torch.pi/2)*" + secondParameter + ")";
-	std::string imag = "(1/(" + firstParameter + "*torch.pow(omegas,"+ secondParameter +")))*torch.sin((torch.pi/2)*" + secondParameter + ")";
+	std::string real = "(1/(" + firstParameter + "*torch.pow(omegas,"+ secondParameter +")))*torch.cos("+ hpi +"*" + secondParameter + ")";
+	std::string imag = "(1/(" + firstParameter + "*torch.pow(omegas,"+ secondParameter +")))*torch.sin("+ hpi +"*" + secondParameter + ")";
 	std::string out = real + '-' + imag + "*1j";
 	return out;
 }