Skip to main content
14-Alexandrite
October 20, 2025
Solved

function to calculate the torque values

  • October 20, 2025
  • 2 replies
  • 582 views

Hello All,
In the attached Mathcad-P10, I am creating a function to calculate the torque values at different x values. It is giving me an error for some values. I appreciate any assistance.

 

SFares_0-1760994023009.png

Regards,

Sam

Best answer by Werner_E

I guess what you had in mind was something like this:

Werner_E_0-1761003111138.png

Could also be written as

Werner_E_1-1761003159231.png

Note that "return" terminates further program execution so no "else" or "else if" is needed.

I replaced your text string "NA" by NaN (Not-a-Number) with appropriate unit to be able to make a plot

Werner_E_2-1761003347840.png

Generally its not a good idea to ask for equality of two float values but its better to rather ask if they are approximately equal within a certain tolerance.

Werner_E_3-1761003484924.png

Prime 10 sheet attached

 

 

2 replies

23-Emerald IV
October 20, 2025

Your function only provides values for when x is larger than 0.8 m (and less than or equal to 1.4 m).

The errors are given for x=0.8 m (which is NOT larger than 0.8 m0, same as for x=0.4 m.

You must define an outcome for ALL possible values of x, so you need an else with the first if, which then should include the cases where x=0.8 m and x < 0.8 m.

 

Success!
Luc

SFares14-AlexandriteAuthor
14-Alexandrite
October 21, 2025

Thanks you Luc!

 

Sam

Werner_E25-Diamond IAnswer
25-Diamond I
October 20, 2025

I guess what you had in mind was something like this:

Werner_E_0-1761003111138.png

Could also be written as

Werner_E_1-1761003159231.png

Note that "return" terminates further program execution so no "else" or "else if" is needed.

I replaced your text string "NA" by NaN (Not-a-Number) with appropriate unit to be able to make a plot

Werner_E_2-1761003347840.png

Generally its not a good idea to ask for equality of two float values but its better to rather ask if they are approximately equal within a certain tolerance.

Werner_E_3-1761003484924.png

Prime 10 sheet attached

 

 

SFares14-AlexandriteAuthor
14-Alexandrite
October 21, 2025

Thank you so much, Werner!

 

Sam