Math issue

Hi,

Ok, I tried to script:

100 * (sin (2 * pi * (10000 / 23)))

but without success. Whats wrong? Osax_additions do not behave like applications. (e.g. with tell statement)
also
using terms from scriptiong addition “satimage”

returns no results. Note: Smile is not on my HD

Hi,

Smile is not needed, download Satimage.OSAX and put it in /Library/ScriptingAdditions/
Restart Script Editor and the script will compile.

Scripting Additions behave like native AppleScript commands, no tell or using terms from blocks

You don’t need a scripting addition at all really. The command line has a tool called bc, and bc can do math. To perform advanced functions in bc use the “-l” switch which uses a math library with bc… for example if you need the sine function s() in bc. The basic way to use bc is to echo the math equation and pipe that to bc. As such the following would work without any scripting additions

set theDegrees to 30
set theRadians to theDegrees * pi / 180
set theSine to do shell script "echo \"s(" & (theRadians as text) & ")\" | bc -l"

regulus6633,

thats kind from you: i like it to solve problems without additions, using the tools i own.

You don’t even need to use the shell:

set y to 100 * (getSine(2 * pi * (10000 / 23)))

on getSine(n)
set x to n mod pi
set answer to 0
set numerator to x
set denominator to 1
set factor to -(x ^ 2)

repeat with i from 3 to 40 by 2
	set answer to answer + numerator / denominator
	set numerator to numerator * factor
	set denominator to denominator * i * (i - 1)
end repeat
if n mod (2 * pi) > pi then
	return -answer
else
	return answer
end if

end getSine

@ Shane Stanley

:lol:
i’m speakless! thanks!