I think you've like a base-rotation, three planar joint, and another, spatial rotation; and you've end effector( EE) position (x,y,z) and orientation, thus you've to solve four equations for like 5 unknowns (thetas), in this case it is better to reduce your problem the base rotation is independent of other angles, it could directly found like atan(y/x), I'm not sure about your coordinate frame, could you add picture or your robot with DH parameters?
and then you could use the position of the EE and solve for thetas(2,3,5) and you can find the final angle from the orientation of the EE.
In other word, you might decouple your problem to EE position and EE orientation and solving first for three unknowns (position), and use that result to solve four other 2 unknowns, see chapter 6 form this book for more inf. about decoupling:
The other way around is by using, Jacobian method, you can get few tips from similar question is here: https://www.researchgate.net/post/How_can_we_find_joint_variables_for_known_position_of_an_end-effector_using_inverse_kinematics_DH_principles_for_more_than_3_dof_manipulator?_tpcectx=profile_questions
you can use neural networks to determine inverse kinematic of your robot.
when links of robot increase calculate of inverse kinematic is very difficult.... one good method is intelligent approach.
you can run your robot in joint space and save position of end effector and position of angles then a neural network for example MLP with 2 layer estimates function that transfers data from work space to joint space. for simplicity you can use neural network toolbox in matlab.
I'm really interested to know more about neural networks and apply it, could you please provide more details, or suggest some resources, on how this thing go around?
I suggest you to follow the advice of Amin Mohammed. By using DH notation (which is the starting point of your problem) you can find the solution(s) of the problem in closed form, therefore with as little as possible computational effort. I'm sure you can also find many matlab scripts for solving it.
Neural networks seems to me definelty an overkill for this kind of problem
It is possible to calculate the IDM and the Direct dynamic model with the modifed DH notation. You can refer to the following publication of Khalil: Wisama Khalil, Denis Creusot. SYMORO+: A SYSTEM FOR THE SYMBOLIC MODELLING
OF ROBOTS. Robotica, Cambridge University Press, 1997, 15, pp.153-161., available here
If you've the symbolic toolbox of Matlab, it worth testing it. I did it for a 3 DOF haptic interface (with and without SYMORO+). However, calculating an IDM of a 5 DOF robot is not an easy task...
what I'm suggest is that, you can get base angle as: theta1=atan2(y1/x1), then you could move to frame (2) where you've (x2,y2=z1+d1,z2), and you can solve the sub-problem of 3dof planar arm between that frame and frame (4), where you've (x4=z5-a4,y4,z4), if I'm not wrong; and finally you may get theta 5 by constructing the complete transformation between frame 1 and frame 5.
You can get the inverse solution by using a software SYMORO where the inverse solution is obtained by just entering the DH parameters. not only the inverse solution, in addition u will get all the other necessary info about the robot