(* 0.25 (+ 10 (* a a a) (* 2 (+ 5 a))))
)
(defun _sin
( x
/ __sin k r
) ;; x - angle in radians
(defun __sin
( x n
/ factorial
)
)
((if (= (rem n
2) 0) + -) (/ (expt x
(1+ (* 2 n
))) (factorial
(1+ (* 2 n
))))) )
(while (<= (setq k
(1+ k
)) 200) ;; Tyler order - 200 expressions (setq r
(+ r
(__sin x k
))) )
(+ x r)
)
;|
(f 1)
>> 5.75 ; minimal value of chosen interval
(f 4.5)
>> 30.0313 ; the result we're looking for
(f 10)
>> 260.0 ; maximal value of chosen interval
(fooInv f 30.0313) ; a=1, b=10, n=9 ['(1 2 3 4 5 6 7 8 9 10)]
>> 4.5231
(fooInv f 30.0313) ; a=1, b=10, n=18 ['(1 1.5 2 2.5 3 3.5 4 4.5 5 5.5 6 6.5 7 7.5 8 8.5 9 9.5 10)] ; here the actual 'b' arg is suppled for running, hence (f b) is invoked and that makes 'fooInv' near exact function
>> 4.5 ; exactly
(fooInv f 30.0313) ; a=1, b=8, n=2 ['(1 4.5 8)]
>> 4.50001 ; close enough
Using fooInv between min and max values of looking interval
(fooInv f 50.0) ; a=1, b=10, n=9 ['(1 2 3 4 5 6 7 8 9 10)]
>> 5.51922
(fooInv f 50.0) ; a=1, b=10, n=99
>> 5.52816 ; this result should be more accurate
Proof
(f 5.52816)
>> 50.0 ; exactly
|;
;|
(_sin (/ pi 2.0))
>> 1.0
(rtos (/ pi 2.0) 2 20)
"1.570796326794896"
Interestingly I have this number from here : http://ronleigh.com/autolisp/ales15.htm
3.1415926535897932385 / 2 = 1.57079632679489661925
(rtos (fooInv _sin 1.0) 2 20) ; a=1.570796326794891, b=1.570796326794901, n=10000
Command: (rtos (fooInv _sin 1.0) 2 20)
Specify minimal X value of looking interval : 1.570796326794891
Specify maximal X value of looking interval : 1.570796326794901
Specify segmentation of looking interval <100> : 10000
"1.570796326794900" - but there is probably mistake as 00 were repeating at the end (it looks like (rtos) rounded last 6 digit up to 10) :
Command: (rtos 1.57079632679489661925 2 20)
"1.570796326794896" from this output it looks that that isn't the case...
=> PI = (rtos (* 2.0 1.570796326794900) 2 20) >> "3.141592653589800" - but there is probably mistake as 00 were repeating at the end
|;
(defun fooInv
( f b
/ args genargslst AddSpline AddLine L r
)
(defun genargslst
( / a b n dx k r
) (setq a
(getreal "\nSpecify minimal X value of looking interval : ")) (setq b
(getreal "\nSpecify maximal X value of looking interval : ")) (setq n
(getint "\nSpecify segmentation of looking interval <100> : ")) )
(prompt "\nYou specified number 1 - that's not allowed...") (setq n
(getint "\nSpecify segmentation of looking interval <100> : ")) )
)
)
)
(defun AddSpline
( 3DPtLst
/ r
) (
)
)
); setq r
)
); cond
r
); defun
p1 p2
)
)
(
"\nThe argument 'b' is not contained within f(x),
\nwhich may lead to not enough accurate result
\nalthough that would make this sub useless.
\n"
)
); and
nil
); progn
)
(prompt "\nThe supplied function 'f' errors out on some of the provided arguments.") )
(
)
)
)
)
)
); cond
r
); defun