Functions: Difference between revisions

From Seamly
Content added Content deleted
m (entered all "A" headings)
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
When writing out measurement equations in Seamly, there are many mathematical functions that one may use to make them work seamlessly. This is [to be] a list of the functions, with a one-line example of how to actually use them in equations. Functions are served by the muparser math library.<ref>https://forum.seamly.net/t/math-functions-nested-if-statement/2053</ref>
When writing out measurement equations in Seamly, there are many mathematical functions that one may use to make them work seamlessly. This is a list of the functions, with a one-line example of how to actually use them in equations. Functions are served by the muparser math library.<ref>https://forum.seamly.net/t/math-functions-nested-if-statement/2053</ref>
[[File:MeasurementDialogFunctionsTable.png|alt=The Functions table in the Measurement Dialog is an excellent place to find most of the available algebraic functions of Seamly.|thumb|A picture of the Functions table.]]
[[File:MeasurementDialogFunctionsTable.png|alt=The Functions table in the Measurement Dialog is an excellent place to find most of the available algebraic functions of Seamly.|thumb|A picture of the Functions table.]]


Line 11: Line 11:
'''*''' times (3*4=12)
'''*''' times (3*4=12)


'''/''' dividedby (3/4=.75)
'''/''' divided by (3/4=.75)


'''^''' to the power of (3^4=81)
'''^''' to the power of (3^4=81)


== Advanced Functions ==
== Advanced Functions ==
Most of these functions are found in the table, however there are several which depend on your ability to construct an IF function in Seamly. As such, I will discuss the IF statement, (which is not in the list,) first, & then proceed in alphabetical order as the functions appear in the list. It may be better to list them by branch of mathematics, but for now the list, & thus the alphabet, has priority.
Most of these functions are found in the table, however IF, (& possibly others?) are not in the list. I will list IF first, & then proceed in alphabetical order as the functions appear in the list. It may be better to list them by branch of mathematics, but for now the list, & thus the alphabet, has priority.


=== IF function ===


Variables are always welcome to be equations, they do not need to be numerals.
* '''if a<b then c else d''' looks like '''( a<b ? c : d)''' in Seamly2D formulas.

* '''if e<f then f else g''' looks like '''(e<f ? f : g)'''
==== IF function ====

*'''if a<b then c else d''' looks like '''( a<b ? c : d)''' in Seamly2D formulas.
*'''if e<f then f else g''' looks like '''(e<f ? f : g)'''
* When d is another test, then it looks like: '''( a<b ? c : (e<f ? f : g) )'''<ref>[https://forum.seamly.net/t/math-functions-nested-if-statement/2053/5?u=pneumarian https://forum.seamly.net/t/math-functions-nested-if-statement/2053/5]</ref>
* When d is another test, then it looks like: '''( a<b ? c : (e<f ? f : g) )'''<ref>[https://forum.seamly.net/t/math-functions-nested-if-statement/2053/5?u=pneumarian https://forum.seamly.net/t/math-functions-nested-if-statement/2053/5]</ref>


==== _pi - π ====
<br />


* '''Definition:''' π is equal to how many times a diameter can go around its circle. In Seamly it is taken to the fifth decimal place: 3.14159
* '''Why:''' To work with circles. For instance, if you want to make a circle of a certain circumference, you might use the equation '''<code>head_circ/_pi/2</code>'''

<br />
==== abs - absolute value ====
==== abs - absolute value ====
abs(3-4)=1<ref>[https://forum.seamly.net/t/negative-numbers/2043/2?u=pneumarian https://forum.seamly.net/t/negative-numbers/2043/2]</ref>


* '''Definition:''' ''a nonnegative number equal in numerical value to a given real number.''<ref>https://www.merriam-webster.com/dictionary/absolute%20value</ref>In other words, "How far is this number from zero?" -2 is still absolutely 2 spaces from zero, even if it's on the wrong side of the tracks.
==== acos - arcus cosine function working with radians ====
acos(-1)=3.14159


* Use: '''abs(''N'')'''<ref>[https://forum.seamly.net/t/negative-numbers/2043/2?u=pneumarian https://forum.seamly.net/t/negative-numbers/2043/2]</ref> always returns a positive value
acos(1)=0
(-1≤''N''≤1)


* '''Why:''' Because in some equations you might want the difference between two measurements to come back positive regardless of which is larger. I'm sure I've read about such occurrences somewhere.
==== acosD - arcus cosine function working with degrees ====
acosD(-1)=180


==== acos - arcus cosine function working with radians ====
acosD(1)=0
(-1≤''N''≤1)
Use: '''acos(''N'')''' where -1≤''N''≤1


==== acosh - hyperbolic arcus cosine function ====
==== acosD - arcus cosine function working with degrees ====
Use: '''acosD(''N'')''' where -1≤''N''≤1
acosh(1)=0


==== acosh - hyperbolic arcus cosine function ====
acosh(2)=1.31696
(''N'' 1)
Use: '''acosh(''N'')''' where ''N''≥1


==== asin - arcus sine function working with radians ====
==== asin - arcus sine function working with radians ====
Use: '''asin(''N'')''' where -1≤''N''≤1


==== asinD ====
==== asinD - arcus sine function working with degrees ====
Use: '''asinD(''N'')''' where -1≤''N''≤1


==== asinh ====
==== asinh - hyperbolic arcus sine function ====
Use: '''asinh(''N'')'''


==== atan ====
==== atan - arcus tangens function working with radians ====
Use: '''atan(''N'')'''


==== atanD ====
==== atanD - arcus tangens function working with degrees ====
Use: '''atanD(''N'')'''


==== atanh ====
==== atanh - hyperbolic arcur tangens function ====
Use: '''atanh(''N'')''' where -1<''N''<1


==== avg - (average,) mean value of all arguments ====
==== avg - (average,) mean value of all arguments ====
Use: '''avg(''N1'';''N2'';''N3'';…)'''
<br />

==== cos - cosine function working with radians ====
Use: '''cos(''N'')'''

==== cosD - cosine function working with degrees ====
Use: '''cosD(''N'')'''

==== cosh - hyperbolic cosine ====
Use: '''cosh(''N'')'''

==== degTorad - converts degrees to radian ====
Use: '''degTorad(''N'')'''

==== exp - ''e'' raised to the power of x ====
Use: '''exp(''N'')''' If you have as much a clue what this is for as I do, may I suggest the Wikipedia article on the [https://en.wikipedia.org/wiki/E_(mathematical_constant) number ''e'']?

==== fmod - Returns the floating-point remainder of numer/denom (rounded towards zero) ====
Use: '''fmod(''N'';''D'')'''

==== ln - logarithm to base e (2.71828…) ====
Use: '''ln(''N'')''' where N>0

==== log - logarithm to the base 10 ====
Use: '''log(''N'')''' where N>0

==== log10 - logarithm to the base 10 ====
Use: '''log10(''N'')''' where N>0

==== log2 - logarithm to the base 2 ====
Use: '''log2(''N'')''' where N>0

====[[Max (function)|max]] - max of all arguments ====
Use: '''max(''N'';''N1'';''N2'';…)'''

====[[Min (function)|min]] - min of all arguments ====
Use: '''min(''N'';''N1'';''N2'';…)'''

==== radTodeg - converts radian to degrees ====
Use: '''radTodeg(''N'')'''

==== rint - round to nearest integer ====
Use: '''rint(''N'')'''

==== sign - sign function -1 if x<0; 1 if x>0 ====
Use: '''sign(''N'')'''

==== sin - sine function working with radians ====
Use: '''sin(''N'')'''

==== sinD - sine function working with degrees ====
Use: '''sinD(''N'')'''

==== sinh - hyperbolic sine function ====
Use: '''sinh(''N'')'''

==== sqrt - square root of a value ====
Use: '''sqrt(''N'')''' where N≥0

==== sum - sum of all arguments ====
Use: '''sum(''N'';''N1'';''N2'';…)'''

==== tan - tangens function working with radians ====
Use: '''tan(''N'')'''

==== tanD - tangens function working with degrees ====
Use: '''tanD(''N'')'''

==== tanh - hyperbolic tangens function ====
Use: '''tanh(''N'')'''


== Bibliography ==
== Bibliography ==

Latest revision as of 18:29, 1 August 2020

When writing out measurement equations in Seamly, there are many mathematical functions that one may use to make them work seamlessly. This is a list of the functions, with a one-line example of how to actually use them in equations. Functions are served by the muparser math library.[1]

The Functions table in the Measurement Dialog is an excellent place to find most of the available algebraic functions of Seamly.
A picture of the Functions table.

Basic Functions[edit | edit source]

These are functions which are so basic that they didn't get included in the list

+ plus (3+4=7)

- minus (3-4=-1)

* times (3*4=12)

/ divided by (3/4=.75)

^ to the power of (3^4=81)

Advanced Functions[edit | edit source]

Most of these functions are found in the table, however IF, (& possibly others?) are not in the list. I will list IF first, & then proceed in alphabetical order as the functions appear in the list. It may be better to list them by branch of mathematics, but for now the list, & thus the alphabet, has priority.


Variables are always welcome to be equations, they do not need to be numerals.

IF function[edit | edit source]

  • if a<b then c else d looks like ( a<b ? c : d) in Seamly2D formulas.
  • if e<f then f else g looks like (e<f ? f : g)
  • When d is another test, then it looks like: ( a<b ? c : (e<f ? f : g) )[2]

_pi - π[edit | edit source]

  • Definition: π is equal to how many times a diameter can go around its circle. In Seamly it is taken to the fifth decimal place: 3.14159
  • Why: To work with circles. For instance, if you want to make a circle of a certain circumference, you might use the equation head_circ/_pi/2


abs - absolute value[edit | edit source]

  • Definition: a nonnegative number equal in numerical value to a given real number.[3]In other words, "How far is this number from zero?" -2 is still absolutely 2 spaces from zero, even if it's on the wrong side of the tracks.
  • Use: abs(N)[4] always returns a positive value
  • Why: Because in some equations you might want the difference between two measurements to come back positive regardless of which is larger. I'm sure I've read about such occurrences somewhere.

acos - arcus cosine function working with radians[edit | edit source]

Use: acos(N) where -1≤N≤1

acosD - arcus cosine function working with degrees[edit | edit source]

Use: acosD(N) where -1≤N≤1

acosh - hyperbolic arcus cosine function[edit | edit source]

Use: acosh(N) where N≥1

asin - arcus sine function working with radians[edit | edit source]

Use: asin(N) where -1≤N≤1

asinD - arcus sine function working with degrees[edit | edit source]

Use: asinD(N) where -1≤N≤1

asinh - hyperbolic arcus sine function[edit | edit source]

Use: asinh(N)

atan - arcus tangens function working with radians[edit | edit source]

Use: atan(N)

atanD - arcus tangens function working with degrees[edit | edit source]

Use: atanD(N)

atanh - hyperbolic arcur tangens function[edit | edit source]

Use: atanh(N) where -1<N<1

avg - (average,) mean value of all arguments[edit | edit source]

Use: avg(N1;N2;N3;…)

cos - cosine function working with radians[edit | edit source]

Use: cos(N)

cosD - cosine function working with degrees[edit | edit source]

Use: cosD(N)

cosh - hyperbolic cosine[edit | edit source]

Use: cosh(N)

degTorad - converts degrees to radian[edit | edit source]

Use: degTorad(N)

exp - e raised to the power of x[edit | edit source]

Use: exp(N) If you have as much a clue what this is for as I do, may I suggest the Wikipedia article on the number e?

fmod - Returns the floating-point remainder of numer/denom (rounded towards zero)[edit | edit source]

Use: fmod(N;D)

ln - logarithm to base e (2.71828…)[edit | edit source]

Use: ln(N) where N>0

log - logarithm to the base 10[edit | edit source]

Use: log(N) where N>0

log10 - logarithm to the base 10[edit | edit source]

Use: log10(N) where N>0

log2 - logarithm to the base 2[edit | edit source]

Use: log2(N) where N>0

max - max of all arguments[edit | edit source]

Use: max(N;N1;N2;…)

min - min of all arguments[edit | edit source]

Use: min(N;N1;N2;…)

radTodeg - converts radian to degrees[edit | edit source]

Use: radTodeg(N)

rint - round to nearest integer[edit | edit source]

Use: rint(N)

sign - sign function -1 if x<0; 1 if x>0[edit | edit source]

Use: sign(N)

sin - sine function working with radians[edit | edit source]

Use: sin(N)

sinD - sine function working with degrees[edit | edit source]

Use: sinD(N)

sinh - hyperbolic sine function[edit | edit source]

Use: sinh(N)

sqrt - square root of a value[edit | edit source]

Use: sqrt(N) where N≥0

sum - sum of all arguments[edit | edit source]

Use: sum(N;N1;N2;…)

tan - tangens function working with radians[edit | edit source]

Use: tan(N)

tanD - tangens function working with degrees[edit | edit source]

Use: tanD(N)

tanh - hyperbolic tangens function[edit | edit source]

Use: tanh(N)

Bibliography[edit | edit source]