Community Tip - You can change your system assigned username to something more personal in your community settings. X
I wrote pseudocode but don't know how to write it in Macthcad
Can you guys show me how would you write this in MATHCAD?
IF a>0 THEN
tol = 10^-5
x=a/2
DO
y=(x+a/x)/2
e=(y-x)/y
x=y
IF e<tol EXIT
END DO
SquareRoot=x
ELSE
SquareRoot=0
END IF
Solved! Go to Solution.
Hi,
Mathcad gives you the option to write sub-programs as functions, see attachement.
all of the program tools are available in the programming toolbar at the top of the mathcad window, most of them are replicated as short-cut key combinations:
Similar functions are available from the ribbon in MC prime, but (as far as I know) there are no short-cut keys
Otherwise the functionality should be similar (and translateable)
Note that when using the program feature it is the left arrow for assignement not :=
All variables used within the program can use variables already defined (above) in the work sheet unless otherwise redefined in the program or as parameters, but ONLY variables that are returned (as the example) will be accessible to the rest of the work sheet; all other assignement are only valid in the scope of the program fragment.
Hope this helps.
Andy
You could also write a function to compare and swap strings ( as your other post) - a for loop or while loop would allow you to iterate through the array.
Message was edited by: A Westerman
Here is an example.
I added a version that accounts for negative input values.
Hi,
Mathcad gives you the option to write sub-programs as functions, see attachement.
all of the program tools are available in the programming toolbar at the top of the mathcad window, most of them are replicated as short-cut key combinations:
Similar functions are available from the ribbon in MC prime, but (as far as I know) there are no short-cut keys
Otherwise the functionality should be similar (and translateable)
Note that when using the program feature it is the left arrow for assignement not :=
All variables used within the program can use variables already defined (above) in the work sheet unless otherwise redefined in the program or as parameters, but ONLY variables that are returned (as the example) will be accessible to the rest of the work sheet; all other assignement are only valid in the scope of the program fragment.
Hope this helps.
Andy
You could also write a function to compare and swap strings ( as your other post) - a for loop or while loop would allow you to iterate through the array.
Message was edited by: A Westerman