diff --git a/unix/main.c b/unix/main.c
index 1c0f78f8b9e879a7ee434ae519fdc4fd740c8d5a..faf8e5b276a82676c1574719541e32af035d26e1 100644
--- a/unix/main.c
+++ b/unix/main.c
@@ -176,3 +176,9 @@ int main(int argc, char **argv) {
     //printf("total bytes = %d\n", m_get_total_bytes_allocated());
     return 0;
 }
+
+// for sqrt
+#include <math.h>
+machine_float_t machine_sqrt(machine_float_t x) {
+    return sqrt(x);
+}
diff --git a/unix/mpyconfig.h b/unix/mpyconfig.h
index 605b2324ed838c2810b021bea9856e2dcd2427be..f187cbb4ea3fcae9824958cb856313aa982d5357 100644
--- a/unix/mpyconfig.h
+++ b/unix/mpyconfig.h
@@ -14,3 +14,5 @@ typedef int64_t machine_int_t; // must be pointer size
 typedef uint64_t machine_uint_t; // must be pointer size
 typedef void *machine_ptr_t; // must be of pointer size
 typedef double machine_float_t;
+
+machine_float_t machine_sqrt(machine_float_t x);