Solar Azimuth angle Derivation
What I think you're trying to do is workable, but approximate. You first find the Sun's geographical position (GP), the point on the Earth where the Sun is in zenith at the time of the observation. You start by finding the Sun's GP latitude (its declination). It's approximately 23 degrees times the sine of ((days since the vernal equinox)times 360/365). Then you find its longitude as the ((hours since local apparent noon)times(15 degrees) + observer's west longitude). You will have three points, vertices of a spherical triangle: observer's location, Sun's GP, and the north pole. The angle at the pole is the difference between the longitudes of the Sun's GP and the observer. The sides between the pole and the other two points are 90 degrees minus their latitudes. All that's needed to solve a spherical triangle is the arc length of two sides and their included angle. Using the law of cosines for spherical triangles, find the arc distance between the observer and the Sun's GP. The altitude of the sun will be 90 degrees minus that number. Find the angle at the observer using the law of sines for spherical triangles. That will be the Sun's azimuth.