Safety factor

The static stress state at a certain point in a material is defined by three principals. The material is characterised by its tensile and compressive strengths ( equal for ductiles ).
This script computes the safety factor at the point using either :
    - the maximum shear stress criterion (9) for ductiles, or
    - the modified Mohr criterion (10) for brittle materials.
All stresses and strengths in the same units. Empty boxes default to zero.
Enter three principal stresses    
and tensile, compressive strengths      
The corresponding safety factor is