PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, August 16, 2022

[FIXED] Why is the ratio of the Surface Area to Volume Ratios of a Octahedron and Cube, a constant, not reflected in my program?

 August 16, 2022     debugging, geometry, math, output, python     No comments   

Issue

I've reached a wall in publishing my paper due to the issue of two platonic solids I'm coding for their SA:V: The cube and octahedron.

Normally, when one derivates the SA:V ratio for a cube and octahedron, it will come out to 6/a and (3*sqrt(6))/a, respectively.

When you take those ratios as a ratio, you get a constant non 1:1 ratio for all size regimes so, how is my output a 1:1 relationship?

Output (click link):

Graph of Ratios:

Table

Relevant code for both shapes in all instances for user request, tabulation, and graphing (ignore icosahedron code): First Instance:

    elif name_of_polyhedron == 'Octahedron':
        a = d/math.sqrt(2)
        SA_vex_octa = ((2*math.sqrt(3))*a**2)
        V_vex_octa = (((math.sqrt(2))/(3))*a**3)
        ratio_vex_octa = (SA_vex_octa/V_vex_octa)
        print('The surface area of your octahedron is as follows:' +str(SA_vex_octa)+ 'm^2')
        print('The volume of your octahedron is as follows:' +str(V_vex_octa)+ 'm^3')
        print('The surface area to volume ratio of your octahedron is as follows:' 
        +str(ratio_vex_octa))
        print('See how your ratio compares below!')
    elif name_of_polyhedron == 'Icosahedron':
        a = 4*(1/(math.sqrt(10+2*math.sqrt(5))))*((1/2)*d)
        SA_vex_icosa = 5*(a**2)*math.sqrt(3)
        V_vex_icosa = (5/12)*(a**3)*(3+sqrt(5))
        ratio_vex_icosa = SA_vex_icosa/V_vex_icosa
        print('The surface area of your icosahedron is as follows:' +str(SA_vex_icosa)+ 'm^2')
        print('The volume of your icosahedron is as follows:' +str(V_vex_icosa)+ 'm^3')
        print('The surface area to volume ratio of your icosahedron is as follows:' 
        +str(ratio_vex_icosa))
        print('See how your ratio compares below!')
    elif name_of_polyhedron == 'Cube':
        a = d/math.sqrt(3)
        SA_vex_cube = 6*a**2
        V_vex_cube = a**3
        ratio_vex_cube = SA_vex_cube/V_vex_cube
        print('The surface area of your cube is as follows:' +str(SA_vex_cube)+ 'm^2')
        print('The volume of your cube is as follows:' +str(V_vex_cube)+ 'm^3')
        print('The surface area to volume ratio of your cube is as follows:' +str(ratio_vex_cube))
        print('See how your ratio compares below!')

#Second Instance

a_4 = d/math.sqrt(2)
SA_vex_octa = (2*math.sqrt(3))*(a_4)**2
V_vex_octa = ((math.sqrt(2))/(3))*(a_4)**3
ratio_vex_octa = SA_vex_octa/V_vex_octa

a_5 = 4*(1/(math.sqrt(10+2*math.sqrt(5))))*((1/2)*d)
SA_vex_icosa = 5*((a_5)**2)*math.sqrt(3)
V_vex_icosa = (5/12)*((a_5)**3)*(3+math.sqrt(5))
ratio_vex_icosa = SA_vex_icosa/V_vex_icosa

a_6 = d/math.sqrt(3)
SA_vex_cube = 6*(a_6)**2
V_vex_cube = (a_6)**3
ratio_vex_cube = SA_vex_cube/V_vex_cube

#Third Instance

a_3 = (2/math.sqrt(6))*d
a_4 = d/math.sqrt(2)
a_5 = (2/(math.sqrt(10+2*math.sqrt(5))))*d
a_6 = d/math.sqrt(3)
a_7 = (2/(math.sqrt(3)*(1+math.sqrt(5)))*d)
a_8 = ((2/(math.sqrt(10+2*math.sqrt(5))))*d)
a_9 = ((2/(math.sqrt(50+22*math.sqrt(5))))*d)
a_10 = ((3/(math.sqrt(3)*(3+math.sqrt(5))))*d)
a_11 = ((2/(math.sqrt(50+22*math.sqrt(5))))*d)
SA_vex_tetra = (((a_3)**2)*math.sqrt(3))
V_vex_tetra = ((((a_3)**3)/12)*math.sqrt(2))
ratio_vex_tetra = [SA_vex_tetra/V_vex_tetra]
SA_vex_octa = (2*math.sqrt(3))*(a_4)**2
V_vex_octa = ((math.sqrt(2))/(3))*(a_4)**3
ratio_vex_octa = SA_vex_octa/V_vex_octa
SA_vex_icosa = 5*((a_5)**2)*math.sqrt(3)
V_vex_icosa = (5/12)*(a_5)**3*(3+math.sqrt(5))
ratio_vex_icosa = SA_vex_icosa/V_vex_icosa
SA_vex_cube = 6*(a_6)**2
V_vex_cube = (a_6)**3
ratio_vex_cube = SA_vex_cube/V_vex_cube

Table/Graph where they occur:

import matplotlib.pyplot as plt
from tabulate import tabulate
z = [('Tetrahedon',a_2,'Platonic',d,SA_vex_tetra,V_vex_tetra,ratio_vex_tetra),
   ('Octahedron',a_2,'Platonic',d,SA_vex_octa,V_vex_octa,ratio_vex_octa),
   ('Icosahedron',a_2,'Platonic',d,SA_vex_icosa,V_vex_icosa,ratio_vex_icosa),
   ('Cube',a_2,'Platonic',d,SA_vex_cube,V_vex_cube,ratio_vex_cube),
   ('Dodecahedron',a_2,'Platonic',d,SA_vex_dodeca,V_vex_dodeca,ratio_vex_dodeca),
   ('Cuboctahedron',a_2,'Archimedes',d,SA_vex_cubocta,V_vex_cubocta,ratio_vex_cubocta),
   ('Rhombicuboctahedron',a_2,'Archimedes',d,SA_vex_rhocubocta,V_vex_rhocubocta,ratio_vex_X), 
   ('Snub Cube',a_2,'Archimedes',d,SA_vex_scube,V_vex_scube,ratio_vex_scube),
   ('Snub Dodecahedron',a_2,'Archimedes',d,SA_vex_sndodeca,V_vex_sndodeca,ratio_vex_sndodeca),
   ('Rhombicosidodecahedron',a_2,'Archimedes',d,SA_vex_ridodeca,V_vex_ridodeca,ratio_vex_ridodeca),
   ('Truncated Octahedron',a_2,'Archimedes',d,SA_vex_ridodeca,V_vex_ridodeca,ratio_vex_sndodeca),
   ('Deltoidal Icositetrahedron','Catalan',a_2,d,SA_vex_delicotetra,V_vex_delicotetra,ratio_vex_X),
   ('Great Dodecahedron',a_1,'Kepler-Poinsot',d,SA_cav_gdodeca,V_cav_gdodeca,ratio_cav_gdodeca),
   ('Great Icosahedron',a_1,'Kepler-Poinsot',d,SA_cav_gicosa,V_cav_gicosa,ratio_cav_gicosa),
   ('Great-Stellated Dodecahedron',a_1,'Kepler-Poinsot',d,SA_cav_gsdodeca,V_cav_gsdodeca,ratio_X_X),
   ('Small-Stellated Dodecahedron',a_1,'Kepler Poinsot',d,SA_cav_ssdodeca,V_cav_ssdodeca,X),
   ('Stellated Octahedron',a_1,'Da Vinci',d,SA_cav_stocta,V_cav_stocta,ratio_cav_stocta),
   ('Medial Rhombic Triacontahedron',a_1,'A-R',(Wenninger)',d,SA_cav_mrtria,V_cav_mrtria,X),
   ('Dodecadodecahedron',a_1,'A-R (Wenninger)',d,SA_cav_ddodeca,V_cav_ddodeca,ratio_cav_ddodeca),
   ('Medial Triambic Icosahedron',a_1,'A-R', (Wenninger)',d,SA_cav_mticosa,V_cav_mticosa,X),
   ('Small Ditrigonal Icosidodecahedron',a_1,'A-R',(Wenninger)',d,SA_cav_sdicosi,V_cav_sdicosi,X),
   ('Excavated Dodecahedron',a_1,'A-R',(Wenninger)',d,SA_cav_exdodeca,V_cav_exdodeca,X),
   ('Sphere',a_12,a_12,d,SA_sphere,V_sphere,ratio_sphere)]
   table_1 = tabulate(z, headers=['Shape','Type','Subtype','C.D. (m)',
         'SA (m^2)','V(m^3)','SA:V'], tablefmt='fancy_grid') #orgtbl or f or pretty
   print(table_1)

Platonic_Array_Ratios = [ratio_vex_tetra,ratio_vex_octa,
                         ratio_vex_icosa,ratio_vex_cube,
                         ratio_vex_dodeca,ratio_sphere]



plt.title('Surface Area to Volume Ratio of Platonic Polyhedra Against Referential Sphere for 
Given 
Diameter')
plt.barh(['Tetrahedron', 'Octahedron', 
        'Icosahedron', 'Cube', 
        'Dodecahedron', 'Sphere'], Platonic_Array_Ratios)
plt.show()

# Platonic
plt.scatter(d,ratio_vex_tetra,label='Tetrahedron', color='b')
plt.scatter(d,ratio_vex_octa,label='Octahedron', color='g')
plt.scatter(d,ratio_vex_icosa,label='Icosahedron', color='y')
plt.scatter(d,ratio_vex_cube,label='Cube', color='m')
plt.scatter(d,ratio_vex_dodeca,label='Dodecahedron', color='c')

plt.scatter(d,ratio_sphere,label='Referential Sphere', color='r')
plt.axvline(x=d_vertical_slash, color='k')

plt.title('Comparison of SA:V of Platonic polyhedra against Referential Sphere with D(m)')
plt.xlabel('Circumspherical Diameter/Diagonal (m)')
plt.ylabel('Ratio Index')

plt.grid(alpha=.4,linestyle='--')

plt.xscale("log")

plt.legend(loc = 1)
plt.show()

I've meticulously quadruple checked the calculations by hand and by widgets online...they are all correct and match each other in all of the calculations the program outputs, but something it still wrong. It seems as if one is overwriting the other, but where?

Note: There is no error message in this code. I also apologize for the long code. I had to copy and paste things all together in some cases for reproducibility or just to give greater context. X is just a placeholder for formatting.


Solution

You are calculating "Surface Area to Volume Ratio of Platonic Polyhedra Against Referential Sphere for Given Diameter" [boldface added]

So before you compare the cube to the octahedron, you compare the cube to the sphere of the cube's diameter, and the octahedron to the sphere of the octahedron's diameter.

(I presume this means circumscribed spheres; I'm not going to check inscribed spheres.)

The SA/V ratio of a sphere is 6/d, where d is the diameter.

The maximum diameter of a cube of edge-length a is sqrt(3)a, so the cube/sphere ratio is (6/a)/(6/(sqrt(3)a)) = sqrt(3)

The maximum diameter of an octahedron of edge-length a is sqrt(2)a, so the octahedron/sphere ratio is (3sqrt(6)/a)/(6/(sqrt(2)a)) = sqrt(3)

So the ratio comes out to 1:1, due to the comparison to spheres.



Answered By - Beta
Answer Checked By - Clifford M. (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing