Roots of a function: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) (Rename Perl 6 -> Raku, alphabetize, minor clean-up) |
No edit summary |
||
Line 1,616: | Line 1,616: | ||
Root found at x = 2.000000000 |
Root found at x = 2.000000000 |
||
</pre> |
</pre> |
||
=={{header|Lambdatalk}}== |
|||
<lang scheme> |
|||
1) defining the function: |
|||
{def func {lambda {:x} {+ {* 1 :x :x :x} {* -3 :x :x} {* 2 :x}}}} |
|||
-> func |
|||
2) printing roots: |
|||
{S.map {lambda {:x} |
|||
{if {< {abs {func :x}} 0.0001} |
|||
then {br}- a root found at :x else}} |
|||
{S.serie -1 3 0.01}} |
|||
-> |
|||
- a root found at 7.528699885739343e-16 |
|||
- a root found at 1.0000000000000013 |
|||
- a root found at 2.000000000000002 |
|||
3) printing the roots of the "sin" function between -720° to +720°; |
|||
{S.map {lambda {:x} |
|||
{if {< {abs {sin {* {/ {PI} 180} :x}}} 0.01} |
|||
then {br}- a root found at :x° else}} |
|||
{S.serie {- {* 2 360}} {+ {* 2 360}} 10}} |
|||
-> |
|||
- a root found at -720° |
|||
- a root found at -540° |
|||
- a root found at -360° |
|||
- a root found at -180° |
|||
- a root found at 0° |
|||
- a root found at 180° |
|||
- a root found at 360° |
|||
- a root found at 540° |
|||
- a root found at 720° |
|||
</lang> |
|||
=={{header|Liberty BASIC}}== |
=={{header|Liberty BASIC}}== |