Arduino Nano BLE 33 Sense IMU

Greetings , thanks for your time & assistance.

I am aware that machine learning is a possible way to solve such issues, but for the time being i would like to keep this project as simple as possible. I have already managed to use the examples provided with the library #include <Arduino_LSM9DS1.h> , and i've previously watched some relevant tutorials. (I've also implemented the amag suggestion!) . Unfortunately , because i'm a new member i cannot provide additional information or links all at once .

#include <Arduino_LSM9DS1.h> 
#define Pi 3.141592654
#define SAMPLE_DELAY 100
#define gaccel 9.8
float pitchOld=0;   
float pitchFNew;    //filtered 


void setup()
{
  Serial.begin(9600);
  while(!Serial);
  Serial.println("Started");

  if(!IMU.begin())
  {
    Serial.println("Failed To Initialize IMU!");
    while(1);
  }
}

void loop()
{
  float x,y,z;
  float pitch;  
  float amag; //magnitude of accel vector

  if(IMU.accelerationAvailable()){
  IMU.readAcceleration(x,y,z);
  pitch=(180/Pi)*atan(x/(z*z + y*y));
  delay(1);
  pitchFNew = (0.95*pitchOld) +(0.05*pitch); //lowpass filter 
  delay(1);
  amag  = sqrt(x*x + y*y + z*z); //magnitude of accel vector
  
  Serial.print("LP Pitch : ");
  Serial.println(pitchFNew);
  Serial.print("aMag : ");
  Serial.print(amag);
  Serial.print('\n');
  }
  delay(SAMPLE_DELAY);
}

Edit: #include <Arduino_LSM9DS1.h> #define Pi 3.141592654#define SAMPLE_DELAY 100 - Pastebin.com (link to my arduino code thus far).
Edit2: I have not included the SPI code as it not relevant for the time being.
Edit3:Fixed Edit1