/* BEGIN OUTFILE1 */
load("stringproc")$
/* before maxima top matter */
keepfloat : true$
alias(convfloat,float)$
alias(int_trunc,truncate)$
alias(elapsed_time_seconds,elapsed_real_time)$
alias(ln,log)$
alias(arcsin,asin)$
alias(arccos,acos)$
alias(arctan,atan)$
alias(float_abs,abs)$
mode_declare(display_poles(),fixnum)$
mode_declare(est_size_answer(),float)$
mode_declare(test_suggested_h(),float)$
mode_declare(reached_interval(),boolean)$
mode_declare(display_alot([iter],fixnum),fixnum)$
mode_declare(prog_report([x_start],float,[x_end],float),fixnum)$
mode_declare(check_for_pole(),fixnum)$
mode_declare(atomall(),fixnum)$
mode_declare(log10([x],float),float)$
mode_declare(logitem_timestr([fd],fixnum,[secs_in],number),fixnum)$
mode_declare(omniout_timestr(secs_in,number),fixnum)$
mode_declare(zero_ats_ar(ar,array([40],float)),fixnum)$
mode_declare(ats([mmm_ats],fixnum,[arr_a],completearray([40],float),[arr_b],completearray([40],float),[jjj_ats],fixnum),float)$
mode_declare(att([mmm_att],fixnum,[arr_a],completearray([40],float),[arr_b],completearray([40],float),[jjj_att],fixnum),float)$
mode_declare(logitem_ditto([file],fixnum),fixnum)$
mode_declare(logitem_integer([file],fixnum,[n],fixnum),fixnum)$
mode_declare(logitem_good_digits([file],fixnum,[relerror],float),fixnum)$
mode_declare(logitem_number([file],fixnum,[x],number),fixnum)$
mode_declare(logitem_pole([file],fixnum,[pole],fixnum),fixnum)$
mode_declare(logstart([file],fixnum),fixnum)$
mode_declare(logend([file],fixnum),fixnum)$
mode_declare(chk_data(),fixnum)$
mode_declare(comp_expect_sec([t_end2],float,[t_start2],float,[t2],float,[clock_sec2],float),float)$
mode_declare(comp_percent([t_end2],float,[start2],float,[t2],float),float)$
mode_declare(comp_rad_from_ratio([term1],float,[term2],float,[last_no],fixnum),float)$
mode_declare(comp_ord_from_ratio([term1],float,[term2],float,[last_no],fixnum),float)$
mode_declare(comp_rad_from_three_terms([term1],float,[term2],float,[term3],float,[last_no],fixnum),float)$
mode_declare(comp_ord_from_three_terms([term1],float,[term2],float,[term3],float,[last_no],fixnum),float)$
mode_declare(comp_rad_from_six_terms([term1],float,[term2],float,[term3],float,[term4],float,[term5],float,[term6],float,[last_no],fixnum),float)$
mode_declare(comp_ord_from_six_terms([term1],float,[term2],float,[term3],float,[term4],float,[term5],float,[term6],float,[last_no],fixnum),float)$
mode_declare(neg([nnn],float),float)$
mode_declare(factorial_2([nnn],fixnum),float)$
mode_declare(factorial_1([nnn],fixnum),float)$
mode_declare(factorial_3([mmm],fixnum,[nnn],fixnum),float)$
mode_declare(float([mmm],fixnum),float)$
mode_declare(elaped_time_seconds(),float)$
mode_declare(Si([x],float),float)$
mode_declare(Ci([x],float),float)$
mode_declare(estimated_needed_step_error([x_start],float,[x_end],float,[estimated_h],float,[estimated_answer],float),float)$
mode_declare(my_check_sign([x0],float,[xf],float),float)$
mode_declare(main_prog(),fixnum)$
define_variable(always,1,fixnum )$
define_variable(info,2,fixnum )$
define_variable(debugl,3,fixnum )$
define_variable(debugmassive,4,fixnum )$
define_variable(glob_iolevel,5,fixnum )$
define_variable(glob_yes_pole,4,fixnum )$
define_variable(glob_no_pole,3,fixnum )$
define_variable(glob_not_given,0,fixnum )$
define_variable(glob_no_sing_tests,4,fixnum )$
define_variable(glob_ratio_test,1,fixnum )$
define_variable(glob_three_term_test,2,fixnum )$
define_variable(glob_six_term_test,3,fixnum )$
define_variable(ats_max_terms,40,fixnum )$
define_variable(glob_log_10,0.0,float )$
/* Top Generate Globals Definition */
define_variable(max_unchanged,10,fixnum )$
define_variable(glob__small,0.1e-50,float )$
define_variable(glob_small_float,0.1e-50,float )$
define_variable(glob_smallish_float,0.1e-60,float )$
define_variable(glob_large_float,1.0e100,float )$
define_variable(glob_larger_float,1.1e100,float )$
define_variable(glob__m2,-2.0,float )$
define_variable(glob__m1,-1.0,float )$
define_variable(glob__0,0.0,float )$
define_variable(glob__1,1.0,float )$
define_variable(glob__2,2.0,float )$
define_variable(glob__3,3.0,float )$
define_variable(glob__4,4.0,float )$
define_variable(glob__5,5.0,float )$
define_variable(glob__8,8.0,float )$
define_variable(glob__10,10.0,float )$
define_variable(glob__100,100.0,float )$
define_variable(glob__pi,0.0,float )$
define_variable(glob__0_5,0.5,float )$
define_variable(glob__0_8,0.8,float )$
define_variable(glob__m0_8,-0.8,float )$
define_variable(glob__0_25,0.25,float )$
define_variable(glob__0_125,0.125,float )$
define_variable(glob_prec,1.0e-16,float )$
define_variable(glob_check_sign,1.0,float )$
define_variable(glob_desired_digits_correct,8.0,float )$
define_variable(glob_max_estimated_step_error,0.0,float )$
define_variable(glob_ratio_of_radius,0.1,float )$
define_variable(glob_percent_done,0.0,float )$
define_variable(glob_total_exp_sec,0.1,float )$
define_variable(glob_optimal_expect_sec,0.1,float )$
define_variable(glob_estimated_size_answer,100.0,float )$
define_variable(glob_almost_1,0.9990,float )$
define_variable(glob_clock_sec,0.0,float )$
define_variable(glob_clock_start_sec,0.0,float )$
define_variable(glob_disp_incr,0.1,float )$
define_variable(glob_h,0.1,float )$
define_variable(glob_diff_rc_fm,0.1,float )$
define_variable(glob_diff_rc_fmm1,0.1,float )$
define_variable(glob_diff_rc_fmm2,0.1,float )$
define_variable(glob_diff_ord_fm,0.1,float )$
define_variable(glob_diff_ord_fmm1,0.1,float )$
define_variable(glob_diff_ord_fmm2,0.1,float )$
define_variable(glob_six_term_ord_save,0.1,float )$
define_variable(glob_guess_error_rc,0.1,float )$
define_variable(glob_guess_error_ord,0.1,float )$
define_variable(glob_least_given_sing,9.9e200,float )$
define_variable(glob_least_ratio_sing,9.9e200,float )$
define_variable(glob_least_3_sing,9.9e100,float )$
define_variable(glob_least_6_sing,9.9e100,float )$
define_variable(glob_last_good_h,0.1,float )$
define_variable(glob_max_h,0.1,float )$
define_variable(glob_min_h,0.000001,float )$
define_variable(glob_display_interval,0.1,float )$
define_variable(glob_abserr,0.1e-10,float )$
define_variable(glob_relerr,0.1e-10,float )$
define_variable(glob_min_pole_est,0.1e+10,float )$
define_variable(glob_max_rel_trunc_err,0.1e-10,float )$
define_variable(glob_max_trunc_err,0.1e-10,float )$
define_variable(glob_max_hours,0.0,float )$
define_variable(glob_optimal_clock_start_sec,0.0,float )$
define_variable(glob_optimal_start,0.0,float )$
define_variable(glob_upper_ratio_limit,1.0001,float )$
define_variable(glob_lower_ratio_limit,0.9999,float )$
define_variable(glob_max_sec,10000.0,float )$
define_variable(glob_orig_start_sec,0.0,float )$
define_variable(glob_normmax,0.0,float )$
define_variable(glob_max_minutes,0.0,float )$
define_variable(glob_next_display,0.0,float )$
define_variable(glob_est_digits,1,fixnum )$
define_variable(glob_subiter_method,3,fixnum )$
define_variable(glob_html_log,true,boolean )$
define_variable(glob_min_good_digits,99999,fixnum )$
define_variable(glob_good_digits,0,fixnum )$
define_variable(glob_min_apfp_est_good_digits,99999,fixnum )$
define_variable(glob_apfp_est_good_digits,0,fixnum )$
define_variable(glob_max_opt_iter,10,fixnum )$
define_variable(glob_dump,false,boolean )$
define_variable(glob_djd_debug,true,boolean )$
define_variable(glob_display_flag,true,boolean )$
define_variable(glob_djd_debug2,true,boolean )$
define_variable(glob_h_reason,0,fixnum )$
define_variable(glob_sec_in_minute,60 ,fixnum )$
define_variable(glob_min_in_hour,60,fixnum )$
define_variable(glob_hours_in_day,24,fixnum )$
define_variable(glob_days_in_year,365,fixnum )$
define_variable(glob_sec_in_hour,3600,fixnum )$
define_variable(glob_sec_in_day,86400,fixnum )$
define_variable(glob_sec_in_year,31536000,fixnum )$
define_variable(glob_not_yet_finished,true,boolean )$
define_variable(glob_initial_pass,true,boolean )$
define_variable(glob_not_yet_start_msg,true,boolean )$
define_variable(glob_reached_optimal_h,false,boolean )$
define_variable(glob_optimal_done,false,boolean )$
define_variable(glob_type_given_pole,0,fixnum )$
define_variable(glob_optimize,false,boolean )$
define_variable(glob_look_poles,false,boolean )$
define_variable(glob_dump_closed_form,false,boolean )$
define_variable(glob_max_iter,1000,fixnum )$
define_variable(glob_no_eqs,0,fixnum )$
define_variable(glob_unchanged_h_cnt,0,fixnum )$
define_variable(glob_warned,false,boolean )$
define_variable(glob_warned2,false,boolean )$
define_variable(glob_start,0,fixnum )$
define_variable(glob_iter,0,fixnum )$
/* Bottom Generate Globals Deninition */
completearray(array_y_init,[40],float)$
completearray(array_norms,[40],float)$
completearray(array_fact_1,[40],float)$
completearray(array_1st_rel_error,[2],float)$
completearray(array_last_rel_error,[2],float)$
completearray(array_est_rel_error,[2],float)$
completearray(array_max_est_error,[2],float)$
completearray(array_type_pole,[2],float)$
completearray(array_type_real_pole,[2],float)$
completearray(array_type_complex_pole,[2],float)$
completearray(array_est_digits,[2],float)$
completearray(array_y,[40],float)$
completearray(array_x,[40],float)$
completearray(array_tmp0,[40],float)$
completearray(array_tmp1_g,[40],float)$
completearray(array_tmp1,[40],float)$
completearray(array_tmp2,[40],float)$
completearray(array_tmp3,[40],float)$
completearray(array_tmp4_g,[40],float)$
completearray(array_tmp4,[40],float)$
completearray(array_tmp5,[40],float)$
completearray(array_m1,[40],float)$
completearray(array_y_higher,[2,40],float)$
completearray(array_y_higher_work,[2,40],float)$
completearray(array_y_higher_work2,[2,40],float)$
completearray(array_y_set_initial,[2,40],float)$
completearray(array_given_rad_poles,[2,3],float)$
completearray(array_given_ord_poles,[2,3],float)$
completearray(array_rad_test_poles,[2,4],float)$
completearray(array_ord_test_poles,[2,4],float)$
completearray(array_fact_2,[40,40],float)$
/* before library and user */
/* BEGIN ATS LIBRARY BLOCK */
/* Begin Function number 2*/
omniout_str(iolevel,str) := (
if (glob_iolevel) >= iolevel then ( /* if number 1*/
printf(true,"~a~%",string(str))
)/* end if 1*/
)$ /* End Function number2 */
/* Begin Function number 3*/
omniout_str_noeol(iolevel,str) := (
if (glob_iolevel >= iolevel) then ( /* if number 1*/
printf(true,"~a",string(str))
)/* end if 1*/
)$ /* End Function number3 */
/* Begin Function number 4*/
omniout_labstr(iolevel,label,str) := (
if (glob_iolevel >= iolevel) then ( /* if number 1*/
printf(true,"~a = ~a~%",string(label),string(str))
)/* end if 1*/
)$ /* End Function number4 */
/* Begin Function number 5*/
omniout_float(iolevel,prelabel,prelen,value,vallen,postlabel) := (
if (glob_iolevel >= iolevel) then ( /* if number 1*/
if vallen = 4 then (
printf(true,"~a = ~g ~s ~%",prelabel,value, postlabel)
) else (
printf(true,"~a = ~g ~s ~%",prelabel,value, postlabel)
)/* end if 1*/
)/* end if 0*/
)$ /* End Function number5 */
omniout_int(iolevel,prelabel,prelen,value,vallen,postlabel) := (
if (glob_iolevel >= iolevel) then ( /* if number 0*/
printf(true,"~a = ~d ~a~%",prelabel,value, postlabel),
newline()
)/* end if 0*/
)$ /* End Function number5 */
/* Begin Function number 6*/
omniout_float_arr(iolevel,prelabel,elemnt,prelen,value,vallen,postlabel) := (
if (glob_iolevel >= iolevel) then ( /* if number 0*/
sprint(prelabel,"[",elemnt,"]=",value, postlabel),
newline()
)/* end if 0*/
)$ /* End Function number6 */
logitem_time(fd,secs_in) := (
block(modedeclare([[days_int,hours_int, minutes_int, sec_int, years_int],fixnum,[secs,secs_temp],float ]),
secs : (secs_in),
printf(fd,"
~%"),
if (secs >= 0) then ( /* if number 0*/
years_int : int_trunc(secs / glob_sec_in_year),
sec_temp : mod(int_trunc(secs) , int_trunc(glob_sec_in_year)),
days_int : int_trunc(sec_temp / glob_sec_in_day) ,
sec_temp : mod(sec_temp , int_trunc(glob_sec_in_day)) ,
hours_int : int_trunc(sec_temp / glob_sec_in_hour),
sec_temp : mod(sec_temp , int_trunc(glob_sec_in_hour)),
minutes_int : int_trunc(sec_temp / glob_sec_in_minute),
sec_int : mod(sec_temp , int_trunc(glob_sec_in_minute)),
if ((int_trunc(years_int)) > 0.1) then ( /* if number 1*/
printf(fd,"~d Years ~f Days ~f Hours ~f Minutes ~f Seconds~%",years_int,days_int,hours_int,minutes_int,sec_int)
) elseif
(days_int > 0.1) then ( /* if number 2*/
printf(fd,"~d Days ~d Hours ~d Minutes ~d Seconds~%",days_int,hours_int,minutes_int,sec_int)
) elseif
(hours_int > 0.1) then ( /* if number 3*/
printf(fd,"~d Hours ~d Minutes ~d Seconds~%",hours_int,minutes_int,sec_int)
) elseif
(minutes_int > 0.1) then ( /* if number 4*/
printf(fd,"~d Minutes ~d Seconds~%",minutes_int,sec_int)
) else (
printf(fd,"~d Seconds~%",sec_int)
)/* end if 4*/
) else (
printf(fd," 0.0 Seconds~%")
)/* end if 3*/
,
printf(fd," | ~%")
),0
)$ /* End Function number6 */
/* Begin Function number 7*/
omniout_timestr(secs_in) := (
block(modedeclare([[days_int,hours_int, minutes_int, sec_int, years_int],fixnum,[secs,secs_temp],float ]),
secs : (secs_in),
if (secs >= 0) then ( /* if number 3*/
years_int : int_trunc(secs / glob_sec_in_year),
sec_temp : mod(int_trunc(secs) , int_trunc(glob_sec_in_year)),
days_int : int_trunc(sec_temp / glob_sec_in_day) ,
sec_temp : mod(sec_temp , int_trunc(glob_sec_in_day)) ,
hours_int : int_trunc(sec_temp / glob_sec_in_hour),
sec_temp : mod(sec_temp , int_trunc(glob_sec_in_hour)),
minutes_int : int_trunc(sec_temp / glob_sec_in_minute),
sec_int : mod(sec_temp , int_trunc(glob_sec_in_minute)),
if (years_int > 0) then ( /* if number 4*/
printf(true,"= ~f Years ~f Days ~f Hours ~f Minutes ~f Seconds~%",years_int,days_int,hours_int,minutes_int,sec_int)
) elseif
(days_int > 0.1) then ( /* if number 5*/
printf(true,"= ~d Days ~d Hours ~d Minutes ~d Seconds~%",days_int,hours_int,minutes_int,sec_int)
) elseif
(hours_int > 0.1) then ( /* if number 6*/
printf(true,"= ~d Hours ~d Minutes ~d Seconds~%",hours_int,minutes_int,sec_int)
) elseif
(minutes_int > 0.1) then ( /* if number 7*/
printf(true,"= ~d Minutes ~d Seconds~%",minutes_int,sec_int)
) else (
printf(true,"= ~d Seconds~%",sec_int)
)/* end if 7*/
) else (
printf(true,"= 0.0 Seconds~%")
)/* end if 6*/
),0
)$ /* End Function number7 */
/* Begin Function number 8*/
zero_ats_ar(arr_a) := (
block(modedeclare([ iii],fixnum),
iii : 1,
while (iii <= ats_max_terms) do ( /* do number 1*/
arr_a [iii] : glob__0,
iii : iii + 1
)/* end do number 1*/
),0
)$ /* End Function number8 */
/* Begin Function number 9*/
ats(mmm_ats,arr_a,arr_b,jjj_ats) := (
block(modedeclare([ [iii_ats, lll_ats,ma_ats],fixnum, [ret_ats],float]),
ret_ats : glob__0,
if (jjj_ats <= mmm_ats) then ( /* if number 6*/
ma_ats : mmm_ats + 1,
iii_ats : jjj_ats,
while (iii_ats <= mmm_ats) do ( /* do number 1*/
lll_ats : ma_ats - iii_ats,
if ((lll_ats <= ats_max_terms and (iii_ats <= ats_max_terms) )) then ( /* if number 7*/
ret_ats : ret_ats + c(arr_a[iii_ats])*c(arr_b[lll_ats])
)/* end if 7*/
,
iii_ats : iii_ats + 1
)/* end do number 1*/
)/* end if 6*/
,
ret_ats
)
)$ /* End Function number9 */
/* Begin Function number 10*/
att(mmm_att,arr_aa,arr_bb,jjj_att) := (
block(modedeclare([ [al_att, iii_att,lll_att, ma_att],float , [ret_att],fixnum]),
ret_att : glob__0,
if (jjj_att < mmm_att) then ( /* if number 6*/
ma_att : mmm_att + 2,
iii_att : jjj_att,
while ((iii_att < mmm_att) and (iii_att <= ats_max_terms) ) do ( /* do number 1*/
lll_att : ma_att - iii_att,
al_att : (lll_att - 1),
if ((lll_att <= ats_max_terms and (iii_att <= ats_max_terms) )) then ( /* if number 7*/
ret_att : ret_att + c(arr_aa[iii_att])*c(arr_bb[lll_att])* c(al_att)
)/* end if 7*/
,
iii_att : iii_att + 1
)/* end do number 1*/
,
ret_att : ret_att / c(mmm_att)
)/* end if 6*/
,
ret_att
)
)$ /* End Function number10 */
/* Begin Function number 11*/
logditto(file) := (
printf(file,""),
printf(file,"ditto"),
printf(file," | "),0
)$ /* End Function number11 */
/* Begin Function number 12*/
logitem_integer(file,n) := (
printf(file,""),
printf(file,"~d",n),
printf(file," | "),0
)$ /* End Function number12 */
/* Begin Function number 13*/
logitem_str(file,str) := (
printf(file,""),
printf(file,str),
printf(file," | "),0
)$ /* End Function number13 */
/* Begin Function number 14*/
logitem_good_digits(file,rel_error) := (
block(modedeclare([[good_digits],fixnum]),
printf(file,""),
printf(file,"~d",glob_min_good_digits),
printf(file," | ")
),0
)$ /* End Function number14 */
/* Begin Function number 15*/
log_revs(file,revs) := (
printf(file,revs)
)$ /* End Function number15 */
/* Begin Function number 16*/
logitem_float(file,x) := (
printf(file,""),
printf(file,"~g",x),
printf(file," | "),0
)$ /* End Function number16 */
/* Begin Function number 17*/
logitem_h_reason(file) := (
printf(file,""),
if (glob_h_reason = 1) then ( /* if number 6*/
printf(file,"Max H")
) elseif
(glob_h_reason = 2) then ( /* if number 7*/
printf(file,"Display_interval")
) elseif
(glob_h_reason = 3) then ( /* if number 8*/
printf(file,"Optimal")
) elseif
(glob_h_reason = 4) then ( /* if number 9*/
printf(file,"Pole Accuracy")
) elseif
(glob_h_reason = 5) then ( /* if number 10*/
printf(file,"Min H (Pole)")
) elseif
(glob_h_reason = 6) then ( /* if number 11*/
printf(file,"Pole")
) elseif
(glob_h_reason = 7) then ( /* if number 12*/
printf(file,"Opt Iter")
) else (
printf(file,"Impossible")
)/* end if 12*/
,
printf(file," | "),0
)$ /* End Function number17 */
/* Begin Function number 18*/
logstart(file) := (
printf(file,""),0
)$ /* End Function number18 */
/* Begin Function number 19*/
logend(file) := (
printf(file,"
~%"),0
)$ /* End Function number19 */
/* Begin Function number 20*/
chk_data() := (
block(modedeclare([ [errflag],boolean]),
errflag : false,
if (glob_max_iter < 2) then ( /* if number 12*/
omniout_str(always,"Illegal max_iter"),
errflag : true
)/* end if 12*/
,
if (errflag) then ( /* if number 12*/
quit()
)/* end if 12*/
),0
)$ /* End Function number20 */
/* Begin Function number 21*/
comp_expect_sec(t_end2,t_start2,t2,clock_sec2) := (
block(modedeclare([[ ms2, rrr, sec_left, sub1, sub2], float]),
ms2 : c(clock_sec2),
sub1 : c(t_end2-t_start2),
sub2 : c(t2-t_start2),
if (sub1 = glob__0) then ( /* if number 12*/
sec_left : glob__0
) else (
if (sub2 > glob__0) then ( /* if number 13*/
rrr : (sub1/sub2),
sec_left : rrr * c(ms2) - c(ms2)
) else (
sec_left : glob__0
)/* end if 13*/
)/* end if 12*/
,
sec_left
)
)$ /* End Function number21 */
/* Begin Function number 22*/
comp_percent(t_end2,t_start2, t2) := (
block(modedeclare([ [rrr, sub1, sub2],float]),
sub1 : (t_end2-t_start2),
sub2 : (t2-t_start2),
if (sub2 > glob_small_float) then ( /* if number 12*/
rrr : (glob__100*sub2)/sub1
) else (
rrr : 0.0
)/* end if 12*/
,
rrr
)
)$ /* End Function number22 */
/* Begin Function number 23*/
comp_rad_from_ratio(term1,term2,last_no) := (
/* TOP TWO TERM RADIUS ANALYSIS */
if (float_abs(term2) > glob__0) then ( /* if number 12*/
ret : float_abs(term1 * glob_h / term2)
) else (
ret : glob_larger_float
)/* end if 12*/
,
ret
/* BOTTOM TWO TERM RADIUS ANALYSIS */
)$ /* End Function number23 */
/* Begin Function number 24*/
comp_ord_from_ratio(term1,term2,last_no) := (
/* TOP TWO TERM ORDER ANALYSIS */
if (float_abs(term2) > glob__0) then ( /* if number 12*/
ret : glob__1 + float_abs(term2) * c(last_no) * ln(float_abs(term1 * glob_h / term2))/ln(c(last_no))
) else (
ret : glob_larger_float
)/* end if 12*/
,
ret
/* BOTTOM TWO TERM ORDER ANALYSIS */
)$ /* End Function number24 */
/* Begin Function number 25*/
c(in_val) := (
/* To Force Conversion when needed */
ret : in_val,
ret
/* End Conversion */
)$ /* End Function number25 */
/* Begin Function number 26*/
comp_rad_from_three_terms(term1,term2,term3,last_no) := (
/* TOP THREE TERM RADIUS ANALYSIS */
temp : float_abs(term2*term2*c(last_no)+glob__m2*term2*term2-term1*term3*c(last_no)+term1*term3),
if (float_abs(temp) > glob__0) then ( /* if number 12*/
ret : float_abs((term2*glob_h*term1)/(temp))
) else (
ret : glob_larger_float
)/* end if 12*/
,
ret
/* BOTTOM THREE TERM RADIUS ANALYSIS */
)$ /* End Function number26 */
/* Begin Function number 27*/
comp_ord_from_three_terms(term1,term2,term3,last_no) := (
/* TOP THREE TERM ORDER ANALYSIS */
ret : float_abs((glob__4*term1*term3*c(last_no)-glob__3*term1*term3-glob__4*term2*term2*c(last_no)+glob__4*term2*term2+term2*term2*c(last_no*last_no)-term1*term3*c(last_no*last_no))/(term2*term2*c(last_no)-glob__2*term2*term2-term1*term3*c(last_no)+term1*term3)),
ret
/* TOP THREE TERM ORDER ANALYSIS */
)$ /* End Function number27 */
/* Begin Function number 28*/
comp_rad_from_six_terms(term1,term2,term3,term4,term5,term6,last_no) := (
/* TOP SIX TERM RADIUS ANALYSIS */
if ((term5 # glob__0) and (term4 # glob__0) and (term3 # glob__0) and (term2 # glob__0) and (term1 # glob__0)) then ( /* if number 12*/
rm0 : term6/term5,
rm1 : term5/term4,
rm2 : term4/term3,
rm3 : term3/term2,
rm4 : term2/term1,
nr1 : c(last_no-1)*rm0 - glob__2*c(last_no-2)*rm1 + c(last_no-3)*rm2,
nr2 : c(last_no-2)*rm1 - glob__2*c(last_no-3)*rm2 + c(last_no-4)*rm3,
dr1 : glob__m1/rm1 + glob__2/rm2 - glob__1/rm3,
dr2 : glob__m1/rm2 + glob__2/rm3 - glob__1/rm4,
ds1 : glob__3/rm1 - glob__8/rm2 + glob__5/rm3,
ds2 : glob__3/rm2 - glob__8/rm3 + glob__5/rm4,
if ((float_abs(nr1 * dr2 - nr2 * dr1) = glob__0) or (float_abs(dr1) = glob__0)) then ( /* if number 13*/
rad_c : glob_larger_float,
ord_no : glob_larger_float
) else (
if (float_abs(nr1*dr2 - nr2 * dr1) > glob__0) then ( /* if number 14*/
rcs : ((ds1*dr2 - ds2*dr1 +dr1*dr2)/(nr1*dr2 - nr2 * dr1)),
/* (Manuels) rcs : (ds1*dr2 - ds2*dr1)/(nr1*dr2 - nr2 * dr1) */
ord_no : (rcs*nr1 - ds1)/(glob__2*dr1) -c(last_no)/glob__2,
if (float_abs(rcs) # glob__0) then ( /* if number 15*/
if (rcs > glob__0) then ( /* if number 16*/
rad_c : sqrt(rcs) * float_abs(glob_h)
) else (
rad_c : glob_larger_float,
ord_no : glob_larger_float
)/* end if 16*/
) else (
rad_c : glob_larger_float,
ord_no : glob_larger_float
)/* end if 15*/
) else (
rad_c : glob_larger_float,
ord_no : glob_larger_float
)/* end if 14*/
)/* end if 13*/
) else (
rad_c : glob_larger_float,
ord_no : glob_larger_float
)/* end if 12*/
,
glob_six_term_ord_save : ord_no,
rad_c
/* BOTTOM SIX TERM RADIUS ANALYSIS */
)$ /* End Function number28 */
/* Begin Function number 29*/
comp_ord_from_six_terms(term1,term2,term3,term4,term5,term6,last_no) := (
/* TOP SIX TERM ORDER ANALYSIS */
/* TOP SAVED FROM SIX TERM RADIUS ANALYSIS */
glob_six_term_ord_save
/* BOTTOM SIX TERM ORDER ANALYSIS */
)$ /* End Function number29 */
/* Begin Function number 30*/
factorial_2(nnn) := (
block(modedeclare([[ ret],float]),
ret : nnn!,
ret
)
)$ /* End Function number30 */
/* Begin Function number 31*/
factorial_1(nnn) := (
block(modedeclare([[ ret],float]),
if (nnn <= ats_max_terms) then ( /* if number 12*/
if (array_fact_1[nnn] = 0) then ( /* if number 13*/
ret : factorial_2(nnn),
array_fact_1[nnn] : ret
) else (
ret : array_fact_1[nnn]
)/* end if 13*/
) else (
ret : factorial_2(nnn)
)/* end if 12*/
,
ret
)
)$ /* End Function number31 */
/* Begin Function number 32*/
factorial_1(in) := (
block(modedeclare([[ ret],float]),
ret : (in!),
ret
)
)$ /* End Function number32 */
/* Begin Function number 33*/
neg(in) := (
block(modedeclare([[ ret],float]),
ret : (-in),
ret
)
)$ /* End Function number33 */
/* Begin Function number 34*/
factorial_3(mmm,nnn) := (
block(modedeclare([ [ret],float]),
if ((nnn <= ats_max_terms) and (mmm <= ats_max_terms)) then ( /* if number 12*/
if (array_fact_2[mmm,nnn] = 0) then ( /* if number 13*/
ret : factorial_1(mmm)/factorial_1(nnn),
array_fact_2[mmm,nnn] : ret
) else (
ret : array_fact_2[mmm,nnn]
)/* end if 13*/
) else (
ret : factorial_2(mmm)/factorial_2(nnn)
)/* end if 12*/
,
ret
)
)$ /* End Function number34 */
/* Begin Function number 35*/
log10(x) := (
(log(x)/glob_log_10)
)$ /* End Function number35 */
/* Begin Function number 36*/
c(x) := (
x
)$ /* End Function number36 */
/* Begin Function number 37*/
expt(x,y) := (
if (y = 0.0) then ( /* if number 12*/
1.0
) elseif
((x <= 0.0) and (y < 0.0)) then ( /* if number 13*/
print("expt error x = ",x,"y = ",y)
) else (
(x^y)
)/* end if 13*/
)$ /* End Function number37 */
/* Begin Function number 38*/
estimated_needed_step_error(x_start,x_end,estimated_h,estimated_answer) := (
block ([ desired_abs_gbl_error,range,estimated_steps,step_error],
omniout_float(always,"glob_desired_digits_correct",32,glob_desired_digits_correct,32,""),
desired_abs_gbl_error : expt(glob__10,c( -glob_desired_digits_correct)) * c(float_abs(c(estimated_answer))),
omniout_float(always,"estimated_h",32,estimated_h,32,""),
omniout_float(always,"estimated_answer",32,estimated_answer,32,""),
omniout_float(always,"desired_abs_gbl_error",32,desired_abs_gbl_error,32,""),
range : (x_end - x_start),
omniout_float(always,"range",32,range,32,""),
estimated_steps : range / estimated_h,
omniout_float(always,"estimated_steps",32,estimated_steps,32,""),
step_error : (c(float_abs(desired_abs_gbl_error) /sqrt(c( estimated_steps))/c(ats_max_terms))),
omniout_float(always,"step_error",32,step_error,32,""),
(step_error)
)
)$ /* End Function number38 */
/* END ATS LIBRARY BLOCK */
/* BEGIN USER FUNCTION BLOCK */
/* BEGIN BLOCK 3 */
/* BEGIN USER DEF BLOCK */
exact_soln_y (x) := (block(
(cos(c(x)) - sin(c(x)))
));
/* END USER DEF BLOCK */
/* END BLOCK 3 */
/* END USER FUNCTION BLOCK */
/* before write_aux functions */
/* Begin Function number 2*/
display_poles() := (
block(modedeclare([[rad_given],float]),
if ((glob_type_given_pole = 1) or (glob_type_given_pole = 2)) then ( /* if number 1*/
rad_given : sqrt((array_x[1] - array_given_rad_poles[1,1]) * (array_x[1] - array_given_rad_poles[1,1]) + array_given_rad_poles[1,2] * array_given_rad_poles[1,2]),
omniout_float(always,"Radius of convergence (given) for eq 1 ",4,rad_given,4," "),
omniout_float(always,"Order of pole (given) ",4,array_given_ord_poles[1,1],4," "),
if (rad_given < glob_least_given_sing) then ( /* if number 2*/
glob_least_given_sing : rad_given
)/* end if 2*/
) elseif
(glob_type_given_pole = 3) then ( /* if number 2*/
omniout_str(always,"NO POLE (given) for Equation 1")
) elseif
(glob_type_given_pole = 5) then ( /* if number 3*/
omniout_str(always,"SOME POLE (given) for Equation 1")
) else (
omniout_str(always,"NO info (given) for Equation 1")
)/* end if 3*/
,
if (array_rad_test_poles[1,1] < glob_large_float) then ( /* if number 3*/
omniout_float(always,"Radius of convergence (ratio test) for eq 1 ",4,array_rad_test_poles[1,1],4," "),
if (array_rad_test_poles[1,1]< glob_least_ratio_sing) then ( /* if number 4*/
glob_least_ratio_sing : array_rad_test_poles[1,1]
)/* end if 4*/
,
omniout_float(always,"Order of pole (ratio test) ",4, array_ord_test_poles[1,1],4," ")
) else (
omniout_str(always,"NO POLE (ratio test) for Equation 1")
)/* end if 3*/
,
if ((array_rad_test_poles[1,2] > glob__small) and (array_rad_test_poles[1,2] < glob_large_float)) then ( /* if number 3*/
omniout_float(always,"Radius of convergence (three term test) for eq 1 ",4,array_rad_test_poles[1,2],4," "),
if (array_rad_test_poles[1,2]< glob_least_3_sing) then ( /* if number 4*/
glob_least_3_sing : array_rad_test_poles[1,2]
)/* end if 4*/
,
omniout_float(always,"Order of pole (three term test) ",4, array_ord_test_poles[1,2],4," ")
) else (
omniout_str(always,"NO REAL POLE (three term test) for Equation 1")
)/* end if 3*/
,
if ((array_rad_test_poles[1,3] > glob__small) and (array_rad_test_poles[1,3] < glob_large_float)) then ( /* if number 3*/
omniout_float(always,"Radius of convergence (six term test) for eq 1 ",4,array_rad_test_poles[1,3],4," "),
if (array_rad_test_poles[1,3]< glob_least_6_sing) then ( /* if number 4*/
glob_least_6_sing : array_rad_test_poles[1,3]
)/* end if 4*/
,
omniout_float(always,"Order of pole (six term test) ",4, array_ord_test_poles[1,3],4," ")
) else (
omniout_str(always,"NO COMPLEX POLE (six term test) for Equation 1")
)/* end if 3*/
),0
)$ /* End Function number2 */
/* Begin Function number 3*/
my_check_sign( x0 ,xf) := (
block( [ret],
if (xf > x0) then ( /* if number 3*/
ret : glob__1
) else (
ret : glob__m1
)/* end if 3*/
,
ret
)
)$ /* End Function number3 */
/* Begin Function number 4*/
est_size_answer()
:= (
block( [ min_size],
min_size : glob_estimated_size_answer,
if (float_abs(array_y[1]) < min_size) then ( /* if number 3*/
min_size : float_abs(array_y[1]),
omniout_float(always,"min_size",32,min_size,32,"")
)/* end if 3*/
,
if (min_size < glob__1) then ( /* if number 3*/
min_size : glob__1,
omniout_float(always,"min_size",32,min_size,32,"")
)/* end if 3*/
,
min_size
)
)$ /* End Function number4 */
/* Begin Function number 5*/
test_suggested_h()
:= (
block ([max_estimated_step_error,hn_div_ho,hn_div_ho_2,hn_div_ho_3,no_terms,est_tmp],
max_estimated_step_error : glob__small,
no_terms : ats_max_terms,
hn_div_ho : glob__0_5,
hn_div_ho_2 : glob__0_25,
hn_div_ho_3 : glob__0_125,
omniout_float(always,"hn_div_ho",32,hn_div_ho,32,""),
omniout_float(always,"hn_div_ho_2",32,hn_div_ho_2,32,""),
omniout_float(always,"hn_div_ho_3",32,hn_div_ho_3,32,""),
est_tmp : float_abs(array_y[no_terms-3] + array_y[no_terms - 2] * hn_div_ho + array_y[no_terms - 1] * hn_div_ho_2 + array_y[no_terms] * hn_div_ho_3),
if (est_tmp >= max_estimated_step_error) then ( /* if number 3*/
max_estimated_step_error : est_tmp
)/* end if 3*/
,
omniout_float(always,"max_estimated_step_error",32,max_estimated_step_error,32,""),
max_estimated_step_error
)
)$ /* End Function number5 */
/* Begin Function number 6*/
track_estimated_error()
:= (
block ([hn_div_ho,hn_div_ho_2,hn_div_ho_3,no_terms,est_tmp],
no_terms : ats_max_terms,
hn_div_ho : glob__0_5,
hn_div_ho_2 : glob__0_25,
hn_div_ho_3 : glob__0_125,
est_tmp : c(float_abs(array_y[no_terms-3])) + c(float_abs(array_y[no_terms - 2])) * c(hn_div_ho) + c(float_abs(array_y[no_terms - 1])) * c(hn_div_ho_2) + c(float_abs(array_y[no_terms])) * c(hn_div_ho_3),
if (glob_prec * c(float_abs(array_y[1])) > c(est_tmp)) then ( /* if number 3*/
est_tmp : c(glob_prec) * c(float_abs(array_y[1]))
)/* end if 3*/
,
if (c(est_tmp) >= c(array_max_est_error[1])) then ( /* if number 3*/
array_max_est_error[1] : c(est_tmp)
)/* end if 3*/
)
)$ /* End Function number6 */
/* Begin Function number 7*/
reached_interval()
:= (
block(modedeclare([[ret],boolean]),
if ((glob_check_sign * array_x[1]) >= (glob_check_sign * glob_next_display - glob_h/glob__10)) then ( /* if number 3*/
ret : true
) else (
ret : false
)/* end if 3*/
,
return(ret)
)
)$ /* End Function number7 */
/* Begin Function number 8*/
display_alot(iter)
:= (
block(modedeclare([[abserr,est_rel_err],float, [closed_form_val_y],float, [ind_var],float, [numeric_val],float, [relerr],float, [term_no],fixnum]),
/* TOP DISPLAY ALOT */
if (reached_interval()) then ( /* if number 3*/
if (iter >= 0) then ( /* if number 4*/
ind_var : array_x[1],
omniout_float(always,"x[1] ",33,ind_var,20," "),
closed_form_val_y : exact_soln_y(ind_var),
omniout_float(always,"y[1] (closed_form) ",33,closed_form_val_y,20," "),
term_no : 1,
numeric_val : array_y[term_no],
abserr : float_abs(numeric_val - closed_form_val_y),
omniout_float(always,"y[1] (numeric) ",33,numeric_val,20," "),
if (c(float_abs(closed_form_val_y)) > c(glob_prec)) then ( /* if number 5*/
relerr : abserr*glob__100/float_abs(closed_form_val_y),
if (c(relerr) > c(glob_prec)) then ( /* if number 6*/
glob_good_digits : -floor(log10(c(relerr))) + 3
) else (
glob_good_digits : 16
)/* end if 6*/
) else (
relerr : glob__m1 ,
glob_good_digits : -16
)/* end if 5*/
,
if (glob_good_digits < glob_min_good_digits) then ( /* if number 5*/
glob_min_good_digits : glob_good_digits
)/* end if 5*/
,
if (glob_apfp_est_good_digits < glob_min_apfp_est_good_digits) then ( /* if number 5*/
glob_min_apfp_est_good_digits : glob_apfp_est_good_digits
)/* end if 5*/
,
if (c(float_abs(numeric_val)) > c(glob_prec)) then ( /* if number 5*/
est_rel_err : c(array_max_est_error[1])*glob__100 * c(sqrt(glob_iter))*c(25)*c(ats_max_terms)/c(float_abs(numeric_val)),
if (est_rel_err > glob_prec) then ( /* if number 6*/
glob_est_digits : -floor(log10(est_rel_err)) + 3
) else (
glob_est_digits : 16
)/* end if 6*/
) else (
relerr : glob__m1 ,
glob_est_digits : -16
)/* end if 5*/
,
array_est_digits[1] : glob_est_digits,
if (glob_iter = 1) then ( /* if number 5*/
array_1st_rel_error[1] : relerr
) else (
array_last_rel_error[1] : relerr
)/* end if 5*/
,
array_est_rel_error[1] : est_rel_err,
omniout_float(always,"absolute error ",4,abserr,20," "),
omniout_float(always,"relative error ",4,relerr,20,"%"),
omniout_int(info,"Desired digits ",32,glob_desired_digits_correct,4," "),
omniout_int(info,"Estimated correct digits ",32,glob_est_digits,4," "),
omniout_int(info,"Correct digits ",32,glob_good_digits,4," ")
,
omniout_float(always,"h ",4,glob_h,20," ")
)/* end if 4*/
/* BOTTOM DISPLAY ALOT */
)/* end if 3*/
),0
)$ /* End Function number8 */
/* Begin Function number 9*/
prog_report(x_start,x_end)
:= (
block(modedeclare([ [clock_sec],float, [opt_clock_sec],float, [clock_sec1],float, [expect_sec],float, [left_sec],float, [percent_done],float, [total_clock_sec],float]),
/* TOP PROGRESS REPORT */
clock_sec1 : elapsed_time_seconds(),
total_clock_sec : (clock_sec1) - (glob_orig_start_sec),
glob_clock_sec : (clock_sec1) - (glob_clock_start_sec),
left_sec : (glob_max_sec) + (glob_orig_start_sec) - (clock_sec1),
expect_sec : comp_expect_sec((x_end),(x_start),(array_x[1]) + (glob_h) ,( clock_sec1) - (glob_orig_start_sec)),
opt_clock_sec : ( clock_sec1) - (glob_optimal_clock_start_sec),
glob_optimal_expect_sec : comp_expect_sec((x_end),(x_start),(array_x[1]) +( glob_h) ,( opt_clock_sec)),
glob_total_exp_sec : glob_optimal_expect_sec + c(total_clock_sec),
percent_done : comp_percent((x_end),(x_start),(array_x[1]) + (glob_h)),
glob_percent_done : percent_done,
omniout_str_noeol(info,"Total Elapsed Time "),
omniout_timestr((total_clock_sec)),
omniout_str_noeol(info,"Elapsed Time(since restart) "),
omniout_timestr((glob_clock_sec)),
if (c(percent_done) < glob__100) then ( /* if number 3*/
omniout_str_noeol(info,"Expected Time Remaining "),
omniout_timestr((expect_sec)),
omniout_str_noeol(info,"Optimized Time Remaining "),
omniout_timestr((glob_optimal_expect_sec)),
omniout_str_noeol(info,"Expected Total Time "),
omniout_timestr((glob_total_exp_sec))
)/* end if 3*/
,
omniout_str_noeol(info,"Time to Timeout "),
omniout_timestr((left_sec)),
omniout_float(info, "Percent Done ",33,percent_done,4,"%")
/* BOTTOM PROGRESS REPORT */
),0
)$ /* End Function number9 */
/* Begin Function number 10*/
check_for_pole()
:= (
block(modedeclare([cnt],fixnum,[ dr1, dr2, ds1, ds2, hdrc],float ,[ m, n],fixnum,[ nr1, nr2],float,[ ord_no],fixnum , [term1, term2, term3, part1, part2, part3, part4, part5, part6, part7, part8, part9, part10, part11, part12, part13, part14, rad_c, rcs, rm0, rm1, rm2, rm3, rm4],float ,[ found_sing],fixnum ,[ h_new, ratio, term, local_test, tmp_rad,tmp_ord, tmp_ratio, prev_tmp_rad],float, [last_no],fixnum),
/* TOP CHECK FOR POLE */
tmp_rad : glob_larger_float,
prev_tmp_rad : glob_larger_float,
tmp_ratio : glob_larger_float,
rad_c : glob_larger_float,
array_rad_test_poles[1,1] : glob_larger_float,
array_ord_test_poles[1,1] : glob_larger_float,
found_sing : 1,
last_no : ats_max_terms - 1 - 10,
cnt : 0,
while (last_no < ats_max_terms-3 and found_sing = 1) do ( /* do number 1*/
tmp_rad : comp_rad_from_ratio(array_y_higher[1,last_no-1],array_y_higher[1,last_no],last_no),
if (float_abs(prev_tmp_rad) > glob__0) then ( /* if number 3*/
tmp_ratio : tmp_rad / prev_tmp_rad
) else (
tmp_ratio : glob_large_float
)/* end if 3*/
,
if ((cnt > 0 ) and (tmp_ratio < glob_upper_ratio_limit) and (tmp_ratio > glob_lower_ratio_limit)) then ( /* if number 3*/
rad_c : tmp_rad
) elseif
(cnt = 0) then ( /* if number 4*/
rad_c : tmp_rad
) elseif
(cnt > 0) then ( /* if number 5*/
found_sing : 0
)/* end if 5*/
,
prev_tmp_rad : tmp_rad,
cnt : cnt + 1,
last_no : last_no + 1
)/* end do number 1*/
,
if (found_sing = 1) then ( /* if number 5*/
if (rad_c < array_rad_test_poles[1,1]) then ( /* if number 6*/
array_rad_test_poles[1,1] : rad_c,
last_no : last_no - 1,
tmp_ord : comp_ord_from_ratio(array_y_higher[1,last_no-1],array_y_higher[1,last_no],last_no),
array_rad_test_poles[1,1] : rad_c,
array_ord_test_poles[1,1] : tmp_ord
)/* end if 6*/
)/* end if 5*/
,
/* BOTTOM general radius test1 */
tmp_rad : glob_larger_float,
prev_tmp_rad : glob_larger_float,
tmp_ratio : glob_larger_float,
rad_c : glob_larger_float,
array_rad_test_poles[1,2] : glob_larger_float,
array_ord_test_poles[1,2] : glob_larger_float,
found_sing : 1,
last_no : ats_max_terms - 1 - 10,
cnt : 0,
while (last_no < ats_max_terms-4 and found_sing = 1) do ( /* do number 1*/
tmp_rad : comp_rad_from_three_terms(array_y_higher[1,last_no-2],array_y_higher[1,last_no-1],array_y_higher[1,last_no],last_no),
if (float_abs(prev_tmp_rad) > glob__0) then ( /* if number 5*/
tmp_ratio : tmp_rad / prev_tmp_rad
) else (
tmp_ratio : glob_large_float
)/* end if 5*/
,
if ((cnt > 0 ) and (tmp_ratio < glob_upper_ratio_limit) and (tmp_ratio > glob_lower_ratio_limit)) then ( /* if number 5*/
rad_c : tmp_rad
) elseif
(cnt = 0) then ( /* if number 6*/
rad_c : tmp_rad
) elseif
(cnt > 0) then ( /* if number 7*/
found_sing : 0
)/* end if 7*/
,
prev_tmp_rad : tmp_rad,
cnt : cnt + 1,
last_no : last_no + 1
)/* end do number 1*/
,
if (found_sing = 1) then ( /* if number 7*/
if (rad_c < array_rad_test_poles[1,2]) then ( /* if number 8*/
array_rad_test_poles[1,2] : rad_c,
last_no : last_no - 1,
tmp_ord : comp_ord_from_three_terms(array_y_higher[1,last_no-2],array_y_higher[1,last_no-1],array_y_higher[1,last_no],last_no),
array_rad_test_poles[1,2] : rad_c,
if (rad_c < glob_min_pole_est) then ( /* if number 9*/
glob_min_pole_est : rad_c
)/* end if 9*/
,
array_ord_test_poles[1,2] : tmp_ord
)/* end if 8*/
)/* end if 7*/
,
/* BOTTOM general radius test1 */
tmp_rad : glob_larger_float,
prev_tmp_rad : glob_larger_float,
tmp_ratio : glob_larger_float,
rad_c : glob_larger_float,
array_rad_test_poles[1,3] : glob_larger_float,
array_ord_test_poles[1,3] : glob_larger_float,
found_sing : 1,
last_no : ats_max_terms - 1 - 10,
cnt : 0,
while (last_no < ats_max_terms-7 and found_sing = 1) do ( /* do number 1*/
tmp_rad : comp_rad_from_six_terms(array_y_higher[1,last_no-5],array_y_higher[1,last_no-4],array_y_higher[1,last_no-3],array_y_higher[1,last_no-2],array_y_higher[1,last_no-1],array_y_higher[1,last_no],last_no),
if (float_abs(prev_tmp_rad) > glob__0) then ( /* if number 7*/
tmp_ratio : tmp_rad / prev_tmp_rad
) else (
tmp_ratio : glob_large_float
)/* end if 7*/
,
if ((cnt > 0 ) and (tmp_ratio < glob_upper_ratio_limit) and (tmp_ratio > glob_lower_ratio_limit)) then ( /* if number 7*/
rad_c : tmp_rad
) elseif
(cnt = 0) then ( /* if number 8*/
rad_c : tmp_rad
) elseif
(cnt > 0) then ( /* if number 9*/
found_sing : 0
)/* end if 9*/
,
prev_tmp_rad : tmp_rad,
cnt : cnt + 1,
last_no : last_no + 1
)/* end do number 1*/
,
if (found_sing = 1) then ( /* if number 9*/
if (rad_c < array_rad_test_poles[1,3]) then ( /* if number 10*/
array_rad_test_poles[1,3] : rad_c,
last_no : last_no - 1,
tmp_ord : comp_ord_from_six_terms(array_y_higher[1,last_no-5],array_y_higher[1,last_no-4],array_y_higher[1,last_no-3],array_y_higher[1,last_no-2],array_y_higher[1,last_no-1],array_y_higher[1,last_no],last_no),
array_rad_test_poles[1,3] : rad_c,
if (rad_c < glob_min_pole_est) then ( /* if number 11*/
glob_min_pole_est : rad_c
)/* end if 11*/
,
array_ord_test_poles[1,3] : tmp_ord
)/* end if 10*/
)/* end if 9*/
,
/* BOTTOM general radius test1 */
/* START ADJUST ALL SERIES */
if (float_abs(glob_min_pole_est) * glob_ratio_of_radius < float_abs(glob_h)) then ( /* if number 9*/
h_new : glob_check_sign * glob_min_pole_est * glob_ratio_of_radius,
omniout_str(always,"SETTING H FOR POLE"),
glob_h_reason : 6,
if (glob_check_sign * glob_min_h > glob_check_sign * h_new) then ( /* if number 10*/
omniout_str(always,"SETTING H FOR MIN H"),
h_new : glob_min_h,
glob_h_reason : 5
)/* end if 10*/
,
term : 1,
ratio : c(1.0),
while (term <= ats_max_terms) do ( /* do number 1*/
array_y[term] : array_y[term]* ratio,
array_y_higher[1,term] : array_y_higher[1,term]* ratio,
array_x[term] : array_x[term]* ratio,
ratio : ratio * h_new / float_abs(glob_h),
term : term + 1
)/* end do number 1*/
,
glob_h : h_new
)/* end if 9*/
/* BOTTOM ADJUST ALL SERIES */
,
if (reached_interval()) then ( /* if number 9*/
display_poles()
)/* end if 9*/
),0
)$ /* End Function number10 */
/* Begin Function number 11*/
atomall()
:= (
block(modedeclare([ [kkk, order_d],fixnum,[ adj2, adj3, temporary, term,temp,temp2],float]),
/* TOP ATOMALL */
/* END OUTFILE1 */
/* BEGIN OUTFILE2 */
/* END OUTFILE2 */
/* BEGIN ATOMHDR1 */
/* emit pre sin 1 $eq_no = 1 */
array_tmp1[1] : sin(array_x[1]),
array_tmp1_g[1] : cos(array_x[1]),
/* emit pre neg FULL $eq_no = 1 */
array_tmp2[1] : neg(array_tmp1[1]),
/* emit pre add CONST FULL $eq_no = 1 i = 1 */
array_tmp3[1] : array_const_0D0[1] + array_tmp2[1],
/* emit pre cos 1 $eq_no = 1 */
array_tmp4[1] : cos(array_x[1]),
array_tmp4_g[1] : sin(array_x[1]),
/* emit pre sub FULL FULL $eq_no = 1 i = 1 */
array_tmp5[1] : array_tmp3[1] - array_tmp4[1],
/* emit pre assign xxx $eq_no = 1 i = 1 $min_hdrs = 5 */
if ( not array_y_set_initial[1,2]) then ( /* if number 1*/
if (1 <= ats_max_terms) then ( /* if number 2*/
temporary : c(array_tmp5[1]) * (expt((glob_h) , c(1))) * c(factorial_3(0,1)),
if (2 <= ats_max_terms) then ( /* if number 3*/
array_y[2] : temporary,
array_y_higher[1,2] : temporary
)/* end if 3*/
,
temporary : c(temporary) / c(glob_h) * c(1),
array_y_higher[2,1] : c(temporary),
0
)/* end if 2*/
)/* end if 1*/
,
kkk : 2,
/* END ATOMHDR1 */
/* BEGIN ATOMHDR2 */
/* emit pre sin ID_LINEAR iii = 2 $eq_no = 1 */
array_tmp1[2] : array_tmp1_g[1] * array_x[2] / c(1),
array_tmp1_g[2] : neg(array_tmp1[1]) * array_x[2] / c(1),
/* emit pre neg FULL $eq_no = 1 */
array_tmp2[2] : neg(array_tmp1[2]),
/* emit pre add CONST FULL $eq_no = 1 i = 2 */
array_tmp3[2] : array_tmp2[2],
/* emit pre cos ID_LINEAR iii = 2 $eq_no = 1 */
array_tmp4[2] : neg(array_tmp4_g[1]) * array_x[2] / c(1),
array_tmp4_g[2] : array_tmp4[1] * array_x[2] / c(1),
/* emit pre sub FULL FULL $eq_no = 1 i = 2 */
array_tmp5[2] : array_tmp3[2] - array_tmp4[2],
/* emit pre assign xxx $eq_no = 1 i = 2 $min_hdrs = 5 */
if ( not array_y_set_initial[1,3]) then ( /* if number 1*/
if (2 <= ats_max_terms) then ( /* if number 2*/
temporary : c(array_tmp5[2]) * (expt((glob_h) , c(1))) * c(factorial_3(1,2)),
if (3 <= ats_max_terms) then ( /* if number 3*/
array_y[3] : temporary,
array_y_higher[1,3] : temporary
)/* end if 3*/
,
temporary : c(temporary) / c(glob_h) * c(2),
array_y_higher[2,2] : c(temporary),
0
)/* end if 2*/
)/* end if 1*/
,
kkk : 3,
/* END ATOMHDR2 */
/* BEGIN ATOMHDR3 */
/* emit pre sin ID_LINEAR iii = 3 $eq_no = 1 */
array_tmp1[3] : array_tmp1_g[2] * array_x[2] / c(2),
array_tmp1_g[3] : neg(array_tmp1[2]) * array_x[2] / c(2),
/* emit pre neg FULL $eq_no = 1 */
array_tmp2[3] : neg(array_tmp1[3]),
/* emit pre add CONST FULL $eq_no = 1 i = 3 */
array_tmp3[3] : array_tmp2[3],
/* emit pre cos ID_LINEAR iii = 3 $eq_no = 1 */
array_tmp4[3] : neg(array_tmp4_g[2]) * array_x[2] / c(2),
array_tmp4_g[3] : array_tmp4[2] * array_x[2] / c(2),
/* emit pre sub FULL FULL $eq_no = 1 i = 3 */
array_tmp5[3] : array_tmp3[3] - array_tmp4[3],
/* emit pre assign xxx $eq_no = 1 i = 3 $min_hdrs = 5 */
if ( not array_y_set_initial[1,4]) then ( /* if number 1*/
if (3 <= ats_max_terms) then ( /* if number 2*/
temporary : c(array_tmp5[3]) * (expt((glob_h) , c(1))) * c(factorial_3(2,3)),
if (4 <= ats_max_terms) then ( /* if number 3*/
array_y[4] : temporary,
array_y_higher[1,4] : temporary
)/* end if 3*/
,
temporary : c(temporary) / c(glob_h) * c(3),
array_y_higher[2,3] : c(temporary),
0
)/* end if 2*/
)/* end if 1*/
,
kkk : 4,
/* END ATOMHDR3 */
/* BEGIN ATOMHDR4 */
/* emit pre sin ID_LINEAR iii = 4 $eq_no = 1 */
array_tmp1[4] : array_tmp1_g[3] * array_x[2] / c(3),
array_tmp1_g[4] : neg(array_tmp1[3]) * array_x[2] / c(3),
/* emit pre neg FULL $eq_no = 1 */
array_tmp2[4] : neg(array_tmp1[4]),
/* emit pre add CONST FULL $eq_no = 1 i = 4 */
array_tmp3[4] : array_tmp2[4],
/* emit pre cos ID_LINEAR iii = 4 $eq_no = 1 */
array_tmp4[4] : neg(array_tmp4_g[3]) * array_x[2] / c(3),
array_tmp4_g[4] : array_tmp4[3] * array_x[2] / c(3),
/* emit pre sub FULL FULL $eq_no = 1 i = 4 */
array_tmp5[4] : array_tmp3[4] - array_tmp4[4],
/* emit pre assign xxx $eq_no = 1 i = 4 $min_hdrs = 5 */
if ( not array_y_set_initial[1,5]) then ( /* if number 1*/
if (4 <= ats_max_terms) then ( /* if number 2*/
temporary : c(array_tmp5[4]) * (expt((glob_h) , c(1))) * c(factorial_3(3,4)),
if (5 <= ats_max_terms) then ( /* if number 3*/
array_y[5] : temporary,
array_y_higher[1,5] : temporary
)/* end if 3*/
,
temporary : c(temporary) / c(glob_h) * c(4),
array_y_higher[2,4] : c(temporary),
0
)/* end if 2*/
)/* end if 1*/
,
kkk : 5,
/* END ATOMHDR4 */
/* BEGIN ATOMHDR5 */
/* emit pre sin ID_LINEAR iii = 5 $eq_no = 1 */
array_tmp1[5] : array_tmp1_g[4] * array_x[2] / c(4),
array_tmp1_g[5] : neg(array_tmp1[4]) * array_x[2] / c(4),
/* emit pre neg FULL $eq_no = 1 */
array_tmp2[5] : neg(array_tmp1[5]),
/* emit pre add CONST FULL $eq_no = 1 i = 5 */
array_tmp3[5] : array_tmp2[5],
/* emit pre cos ID_LINEAR iii = 5 $eq_no = 1 */
array_tmp4[5] : neg(array_tmp4_g[4]) * array_x[2] / c(4),
array_tmp4_g[5] : array_tmp4[4] * array_x[2] / c(4),
/* emit pre sub FULL FULL $eq_no = 1 i = 5 */
array_tmp5[5] : array_tmp3[5] - array_tmp4[5],
/* emit pre assign xxx $eq_no = 1 i = 5 $min_hdrs = 5 */
if ( not array_y_set_initial[1,6]) then ( /* if number 1*/
if (5 <= ats_max_terms) then ( /* if number 2*/
temporary : c(array_tmp5[5]) * (expt((glob_h) , c(1))) * c(factorial_3(4,5)),
if (6 <= ats_max_terms) then ( /* if number 3*/
array_y[6] : temporary,
array_y_higher[1,6] : temporary
)/* end if 3*/
,
temporary : c(temporary) / c(glob_h) * c(5),
array_y_higher[2,5] : c(temporary),
0
)/* end if 2*/
)/* end if 1*/
,
kkk : 6,
/* END ATOMHDR5 */
/* BEGIN OUTFILE3 */
/* Top Atomall While Loop-- outfile3 */
while (kkk <= ats_max_terms) do ( /* do number 1*/
/* END OUTFILE3 */
/* BEGIN OUTFILE4 */
/* emit sin LINEAR $eq_no = 1 */
array_tmp1[kkk] : array_tmp1_g[kkk - 1] * array_x[2] / c(kkk - 1),
array_tmp1_g[kkk] : neg(array_tmp1[kkk - 1]) * array_x[2] / c(kkk - 1),
/* emit neg FULL $eq_no = 1 */
array_tmp2[kkk] : neg(array_tmp1[kkk]),
/* emit NOT FULL - FULL add $eq_no = 1 */
array_tmp3[kkk] : array_tmp2[kkk],
/* emit cos LINEAR $eq_no = 1 */
array_tmp4[kkk] : neg(array_tmp4_g[kkk - 1]) * array_x[2] / c(kkk - 1),
array_tmp4_g[kkk] : array_tmp4[kkk - 1] * array_x[2] / c(kkk - 1),
/* emit FULL - FULL sub $eq_no = 1 */
array_tmp5[kkk] : array_tmp3[kkk] - array_tmp4[kkk],
/* emit assign $eq_no = 1 */
order_d : 1,
if (kkk + order_d <= ats_max_terms) then ( /* if number 1*/
if ( not array_y_set_initial[1,kkk + order_d]) then ( /* if number 2*/
temporary : c(array_tmp5[kkk]) * expt((glob_h) , c(order_d)) * c(factorial_3((kkk - 1),(kkk + order_d - 1))),
array_y[kkk + order_d] : c(temporary),
array_y_higher[1,kkk + order_d] : c(temporary),
term : kkk + order_d - 1,
adj2 : kkk + order_d - 1,
adj3 : 2,
while ((term >= 1) and (term <= ats_max_terms) and (adj3 < order_d + 1)) do ( /* do number 1*/
if (adj3 <= order_d + 1) then ( /* if number 3*/
if (adj2 > 0) then ( /* if number 4*/
temporary : c(temporary) / c(glob_h) * c(adj2)
) else (
temporary : c(temporary)
)/* end if 4*/
,
array_y_higher[adj3,term] : c(temporary)
)/* end if 3*/
,
term : term - 1,
adj2 : adj2 - 1,
adj3 : adj3 + 1
)/* end do number 1*/
)/* end if 2*/
)/* end if 1*/
,
kkk : kkk + 1
)/* end do number 1*/
/* BOTTOM ATOMALL */
/* END OUTFILE4 */
/* BEGIN OUTFILE5 */
),0
/* BOTTOM ATOMALL ??? */
)$ /* End Function number13 */
/* END OUTFILE5 */
/* before write ccc cpp library user def */
/* BEGIN ATS LIBRARY BLOCK */
/* END ATS LIBRARY BLOCK */
/* BEGIN USER FUNCTION BLOCK */
/* BEGIN BLOCK 3 */
/* BEGIN USER DEF BLOCK */
exact_soln_y (x) := (block(
(cos(c(x)) - sin(c(x)))
));
/* END USER DEF BLOCK */
/* END BLOCK 3 */
/* END USER FUNCTION BLOCK */
/* Begin Function number 12*/
main_prog() := (
/* BEGIN OUTFIEMAIN */
block(modedeclare([[ d1,d2,d3,d4,est_err_2,display_max],float,[niii,done_once,
term,ord,order_diff,term_no,html_log_file,iiif,jjjf,
rows,r_order,sub_iter,calc_term,iii],fixnum,[temp_sum],float,[current_iter],fixnum,[
x_start,x_end
],float,[it, opt_iter],fixnum, [tmp],float,[subiter],fixnum,[ est_needed_step_err,estimated_step_error,min_value,est_answer,last_min_pole_est],float,[repeat_it],fixnum],[found_h],boolean),
/* before first input block */
/* BEGIN FIRST INPUT BLOCK */
/* BEGIN BLOCK 1 */
/* BEGIN FIRST INPUT BLOCK */
Digits:32,
max_terms:40,
/* END BLOCK 1 */
/* END FIRST INPUT BLOCK */
/* START OF INITS AFTER INPUT BLOCK */
glob_html_log : true,
/* END OF INITS AFTER INPUT BLOCK */
/* before generate arrays */
/*before arrays initialized */
term : 1,
while (term <= 40) do ( /* do number 1*/
array_y_init[term] : c(0.0),
term : term + 1
)/* end do number 1*/
,
term : 1,
while (term <= 40) do ( /* do number 1*/
array_norms[term] : c(0.0),
term : term + 1
)/* end do number 1*/
,
term : 1,
while (term <= 40) do ( /* do number 1*/
array_fact_1[term] : c(0.0),
term : term + 1
)/* end do number 1*/
,
term : 1,
while (term <= 2) do ( /* do number 1*/
array_1st_rel_error[term] : c(0.0),
term : term + 1
)/* end do number 1*/
,
term : 1,
while (term <= 2) do ( /* do number 1*/
array_last_rel_error[term] : c(0.0),
term : term + 1
)/* end do number 1*/
,
term : 1,
while (term <= 2) do ( /* do number 1*/
array_est_rel_error[term] : c(0.0),
term : term + 1
)/* end do number 1*/
,
term : 1,
while (term <= 2) do ( /* do number 1*/
array_max_est_error[term] : c(0.0),
term : term + 1
)/* end do number 1*/
,
term : 1,
while (term <= 2) do ( /* do number 1*/
array_type_pole[term] : 0,
term : term + 1
)/* end do number 1*/
,
term : 1,
while (term <= 2) do ( /* do number 1*/
array_type_real_pole[term] : 0,
term : term + 1
)/* end do number 1*/
,
term : 1,
while (term <= 2) do ( /* do number 1*/
array_type_complex_pole[term] : 0,
term : term + 1
)/* end do number 1*/
,
term : 1,
while (term <= 2) do ( /* do number 1*/
array_est_digits[term] : 0,
term : term + 1
)/* end do number 1*/
,
term : 1,
while (term <= 40) do ( /* do number 1*/
array_y[term] : c(0.0),
term : term + 1
)/* end do number 1*/
,
term : 1,
while (term <= 40) do ( /* do number 1*/
array_x[term] : c(0.0),
term : term + 1
)/* end do number 1*/
,
term : 1,
while (term <= 40) do ( /* do number 1*/
array_tmp0[term] : c(0.0),
term : term + 1
)/* end do number 1*/
,
term : 1,
while (term <= 40) do ( /* do number 1*/
array_tmp1_g[term] : c(0.0),
term : term + 1
)/* end do number 1*/
,
term : 1,
while (term <= 40) do ( /* do number 1*/
array_tmp1[term] : c(0.0),
term : term + 1
)/* end do number 1*/
,
term : 1,
while (term <= 40) do ( /* do number 1*/
array_tmp2[term] : c(0.0),
term : term + 1
)/* end do number 1*/
,
term : 1,
while (term <= 40) do ( /* do number 1*/
array_tmp3[term] : c(0.0),
term : term + 1
)/* end do number 1*/
,
term : 1,
while (term <= 40) do ( /* do number 1*/
array_tmp4_g[term] : c(0.0),
term : term + 1
)/* end do number 1*/
,
term : 1,
while (term <= 40) do ( /* do number 1*/
array_tmp4[term] : c(0.0),
term : term + 1
)/* end do number 1*/
,
term : 1,
while (term <= 40) do ( /* do number 1*/
array_tmp5[term] : c(0.0),
term : term + 1
)/* end do number 1*/
,
term : 1,
while (term <= 40) do ( /* do number 1*/
array_m1[term] : c(0.0),
term : term + 1
)/* end do number 1*/
,
ord : 1,
while (ord <=2) do ( /* do number 1*/
term : 1,
while (term <= 40) do ( /* do number 2*/
array_y_higher[ord,term] : c(0.0),
term : term + 1
)/* end do number 2*/
,
ord : ord + 1
)/* end do number 1*/
,
ord : 1,
while (ord <=2) do ( /* do number 1*/
term : 1,
while (term <= 40) do ( /* do number 2*/
array_y_higher_work[ord,term] : c(0.0),
term : term + 1
)/* end do number 2*/
,
ord : ord + 1
)/* end do number 1*/
,
ord : 1,
while (ord <=2) do ( /* do number 1*/
term : 1,
while (term <= 40) do ( /* do number 2*/
array_y_higher_work2[ord,term] : c(0.0),
term : term + 1
)/* end do number 2*/
,
ord : ord + 1
)/* end do number 1*/
,
ord : 1,
while (ord <=2) do ( /* do number 1*/
term : 1,
while (term <= 40) do ( /* do number 2*/
array_y_set_initial[ord,term] : c(0.0),
term : term + 1
)/* end do number 2*/
,
ord : ord + 1
)/* end do number 1*/
,
ord : 1,
while (ord <=2) do ( /* do number 1*/
term : 1,
while (term <= 3) do ( /* do number 2*/
array_given_rad_poles[ord,term] : c(0.0),
term : term + 1
)/* end do number 2*/
,
ord : ord + 1
)/* end do number 1*/
,
ord : 1,
while (ord <=2) do ( /* do number 1*/
term : 1,
while (term <= 3) do ( /* do number 2*/
array_given_ord_poles[ord,term] : c(0.0),
term : term + 1
)/* end do number 2*/
,
ord : ord + 1
)/* end do number 1*/
,
ord : 1,
while (ord <=2) do ( /* do number 1*/
term : 1,
while (term <= 4) do ( /* do number 2*/
array_rad_test_poles[ord,term] : c(0.0),
term : term + 1
)/* end do number 2*/
,
ord : ord + 1
)/* end do number 1*/
,
ord : 1,
while (ord <=2) do ( /* do number 1*/
term : 1,
while (term <= 4) do ( /* do number 2*/
array_ord_test_poles[ord,term] : c(0.0),
term : term + 1
)/* end do number 2*/
,
ord : ord + 1
)/* end do number 1*/
,
ord : 1,
while (ord <=40) do ( /* do number 1*/
term : 1,
while (term <= 40) do ( /* do number 2*/
array_fact_2[ord,term] : c(0.0),
term : term + 1
)/* end do number 2*/
,
ord : ord + 1
)/* end do number 1*/
,
/*before symbols initialized */
/* BEGIN SYMBOLS INITIALIZATED */
zero_ats_ar(array_y),
zero_ats_ar(array_x),
zero_ats_ar(array_tmp0),
zero_ats_ar(array_tmp1_g),
zero_ats_ar(array_tmp1),
zero_ats_ar(array_tmp2),
zero_ats_ar(array_tmp3),
zero_ats_ar(array_tmp4_g),
zero_ats_ar(array_tmp4),
zero_ats_ar(array_tmp5),
zero_ats_ar(array_m1),
zero_ats_ar(array_const_1),
array_const_1[1] : c(1),
zero_ats_ar(array_const_0D0),
array_const_0D0[1] : c(0.0),
zero_ats_ar(array_m1),
array_m1[1] : glob__m1,
/* END SYMBOLS INITIALIZATED */
/*before generate factorials init */
/* Initing Factorial Tables */
iiif : 0,
while (iiif <= ats_max_terms) do ( /* do number 1*/
jjjf : 0,
while (jjjf <= ats_max_terms) do ( /* do number 2*/
array_fact_1[iiif] : 0,
array_fact_2[iiif,jjjf] : 0,
jjjf : jjjf + 1
)/* end do number 2*/
,
iiif : iiif + 1
)/* end do number 1*/
,
/* Done Initing Factorial Table */
/*before generate set diff initial */
array_y_set_initial[1,1] : true,
array_y_set_initial[1,2] : false,
array_y_set_initial[1,3] : false,
array_y_set_initial[1,4] : false,
array_y_set_initial[1,5] : false,
array_y_set_initial[1,6] : false,
array_y_set_initial[1,7] : false,
array_y_set_initial[1,8] : false,
array_y_set_initial[1,9] : false,
array_y_set_initial[1,10] : false,
array_y_set_initial[1,11] : false,
array_y_set_initial[1,12] : false,
array_y_set_initial[1,13] : false,
array_y_set_initial[1,14] : false,
array_y_set_initial[1,15] : false,
array_y_set_initial[1,16] : false,
array_y_set_initial[1,17] : false,
array_y_set_initial[1,18] : false,
array_y_set_initial[1,19] : false,
array_y_set_initial[1,20] : false,
array_y_set_initial[1,21] : false,
array_y_set_initial[1,22] : false,
array_y_set_initial[1,23] : false,
array_y_set_initial[1,24] : false,
array_y_set_initial[1,25] : false,
array_y_set_initial[1,26] : false,
array_y_set_initial[1,27] : false,
array_y_set_initial[1,28] : false,
array_y_set_initial[1,29] : false,
array_y_set_initial[1,30] : false,
array_y_set_initial[1,31] : false,
array_y_set_initial[1,32] : false,
array_y_set_initial[1,33] : false,
array_y_set_initial[1,34] : false,
array_y_set_initial[1,35] : false,
array_y_set_initial[1,36] : false,
array_y_set_initial[1,37] : false,
array_y_set_initial[1,38] : false,
array_y_set_initial[1,39] : false,
array_y_set_initial[1,40] : false,
/*before generate init omniout const */
/* set default block */
/* Write Set Defaults */
glob_log_10 : log(10.0),
glob_orig_start_sec : elapsed_time_seconds(),
glob_display_flag : true,
glob_no_eqs : 1,
glob_iter : -1,
opt_iter : -1,
glob_max_iter : 50000,
glob_max_hours : (0.0),
glob_max_minutes : (15.0),
omniout_str(always,"##############ECHO OF PROBLEM#################"),
omniout_str(always,"##############temp/sub_sin_cospostode.ode#################"),
omniout_str(always,"diff ( y , x , 1 ) = neg ( sin ( x ) ) - cos ( x ) ; "),
omniout_str(always,"!"),
omniout_str(always,"/* BEGIN FIRST INPUT BLOCK */"),
omniout_str(always,"Digits:32,"),
omniout_str(always,"max_terms:40,"),
omniout_str(always,"!"),
omniout_str(always,"/* END FIRST INPUT BLOCK */"),
omniout_str(always,"/* BEGIN SECOND INPUT BLOCK */"),
omniout_str(always,"x_start:c(0.1),"),
omniout_str(always,"x_end:c(5.0),"),
omniout_str(always,"array_y_init[0 + 1] : exact_soln_y(x_start),"),
omniout_str(always,"glob_look_poles:true,"),
omniout_str(always,""),
omniout_str(always,""),
omniout_str(always,""),
omniout_str(always,""),
omniout_str(always,""),
omniout_str(always,""),
omniout_str(always,""),
omniout_str(always,"glob_type_given_pole:3,"),
omniout_str(always,""),
omniout_str(always,"/* END SECOND INPUT BLOCK */"),
omniout_str(always,"/* BEGIN OVERRIDE BLOCK */"),
omniout_str(always,"glob_desired_digits_correct:8,"),
omniout_str(always,"glob_max_minutes:(3.0),"),
omniout_str(always,"glob_subiter_method:3,"),
omniout_str(always,"glob_max_iter:100000,"),
omniout_str(always,"glob_upper_ratio_limit:c(1.000001),"),
omniout_str(always,"glob_lower_ratio_limit:c(0.999999),"),
omniout_str(always,"glob_look_poles:false,"),
omniout_str(always,"glob_h:c(0.001),"),
omniout_str(always,"glob_display_interval:c(0.01),"),
omniout_str(always,"/* END OVERRIDE BLOCK */"),
omniout_str(always,"!"),
omniout_str(always,"/* BEGIN USER DEF BLOCK */"),
omniout_str(always,"exact_soln_y (x) := (block("),
omniout_str(always," (cos(c(x)) - sin(c(x))) "),
omniout_str(always,"));"),
omniout_str(always,"/* END USER DEF BLOCK */"),
omniout_str(always,"#######END OF ECHO OF PROBLEM#################"),
glob_unchanged_h_cnt : 0,
glob_warned : false,
glob_warned2 : false,
glob_small_float : glob__0,
glob_smallish_float : glob__0,
glob_large_float : c(1.0e100),
glob_larger_float : c( 1.1e100),
glob_almost_1 : c( 0.99),
/* before second block */
/* TOP SECOND INPUT BLOCK */
/* BEGIN SECOND INPUT BLOCK */
/* BEGIN BLOCK 2 */
/* END FIRST INPUT BLOCK */
/* BEGIN SECOND INPUT BLOCK */
x_start:c(0.1),
x_end:c(5.0),
array_y_init[0 + 1] : exact_soln_y(x_start),
glob_look_poles:true,
glob_type_given_pole:3,
/* END SECOND INPUT BLOCK */
/* BEGIN OVERRIDE BLOCK */
glob_desired_digits_correct:8,
glob_max_minutes:(3.0),
glob_subiter_method:3,
glob_max_iter:100000,
glob_upper_ratio_limit:c(1.000001),
glob_lower_ratio_limit:c(0.999999),
glob_look_poles:false,
glob_h:c(0.001),
glob_display_interval:c(0.01),
/* END OVERRIDE BLOCK */
/* END BLOCK 2 */
/* END SECOND INPUT BLOCK */
/* BEGIN INITS AFTER SECOND INPUT BLOCK */
glob_last_good_h : glob_h,
glob_max_sec : (60.0) * (glob_max_minutes) + (3600.0) * (glob_max_hours),
glob_check_sign : c(my_check_sign(x_start,x_end)),
glob__pi : 3.141592654,
glob_prec : 1.0e-16,
if (glob_optimize) then ( /* if number 9*/
/* BEGIN OPTIMIZE CODE */
omniout_str(always,"START of Optimize"),
/* Start Series -- INITIALIZE FOR OPTIMIZE */
found_h : false,
glob_min_pole_est : glob_larger_float,
last_min_pole_est : glob_larger_float,
glob_least_given_sing : glob_larger_float,
glob_least_ratio_sing : glob_larger_float,
glob_least_3_sing : glob_larger_float,
glob_least_6_sing : glob_larger_float,
glob_min_h : float_abs(glob_min_h) * glob_check_sign,
glob_max_h : float_abs(glob_max_h) * glob_check_sign,
glob_h : float_abs(glob_min_h) * glob_check_sign,
glob_display_interval : c((float_abs(c(glob_display_interval))) * (glob_check_sign)),
display_max : c(x_end) - c(x_start)/glob__10,
if ((glob_display_interval) > (display_max)) then ( /* if number 10*/
glob_display_interval : c(display_max)
)/* end if 10*/
,
chk_data(),
min_value : glob_larger_float,
est_answer : est_size_answer(),
opt_iter : 1,
est_needed_step_err : estimated_needed_step_error(x_start,x_end,glob_h,est_answer),
omniout_float(always,"est_needed_step_err",32,est_needed_step_err,16,""),
estimated_step_error : glob_small_float,
while ((opt_iter <= 100) and ( not found_h)) do ( /* do number 1*/
omniout_int(always,"opt_iter",32,opt_iter,4,""),
array_x[1] : c(x_start),
array_x[2] : c(glob_h),
glob_next_display : c(x_start),
order_diff : 1,
/* Start Series array_y */
term_no : 1,
while (term_no <= order_diff) do ( /* do number 2*/
array_y[term_no] : array_y_init[term_no] * expt(glob_h , c(term_no - 1)) / c(factorial_1(term_no - 1)),
term_no : term_no + 1
)/* end do number 2*/
,
rows : order_diff,
r_order : 1,
while (r_order <= rows) do ( /* do number 2*/
term_no : 1,
while (term_no <= (rows - r_order + 1)) do ( /* do number 3*/
it : term_no + r_order - 1,
if (term_no < ats_max_terms) then ( /* if number 10*/
array_y_higher[r_order,term_no] : array_y_init[it]* expt(glob_h , c(term_no - 1)) / (c(factorial_1(term_no - 1)))
)/* end if 10*/
,
term_no : term_no + 1
)/* end do number 3*/
,
r_order : r_order + 1
)/* end do number 2*/
,
atomall(),
if (glob_check_sign * glob_min_h >= glob_check_sign * glob_h) then ( /* if number 10*/
omniout_str(always,"SETTING H FOR MIN H"),
glob_h : glob_check_sign * float_abs(glob_min_h),
glob_h_reason : 1,
found_h : true
)/* end if 10*/
,
if (glob_check_sign * glob_display_interval <= glob_check_sign * glob_h) then ( /* if number 10*/
omniout_str(always,"SETTING H FOR DISPLAY INTERVAL"),
glob_h_reason : 2,
glob_h : glob_display_interval,
found_h : true
)/* end if 10*/
,
if (glob_look_poles) then ( /* if number 10*/
check_for_pole()
)/* end if 10*/
,
if ( not found_h) then ( /* if number 10*/
est_answer : est_size_answer(),
est_needed_step_err : estimated_needed_step_error(x_start,x_end,glob_h,est_answer),
omniout_float(always,"est_needed_step_err",32,est_needed_step_err,16,""),
estimated_step_error : test_suggested_h(),
omniout_float(always,"estimated_step_error",32,estimated_step_error,32,""),
if (estimated_step_error < est_needed_step_err) then ( /* if number 11*/
omniout_str(always,"Double H and LOOP"),
glob_h : glob_h*glob__2
) else (
omniout_str(always,"Found H for OPTIMAL"),
found_h : true,
glob_h_reason : 3,
glob_h : glob_h/glob__2
)/* end if 11*/
)/* end if 10*/
,
opt_iter : opt_iter + 1
)/* end do number 1*/
,
if (( not found_h) and (opt_iter = 1)) then ( /* if number 10*/
omniout_str(always,"Beginning glob_h too large."),
found_h : false
)/* end if 10*/
,
if (glob_check_sign * glob_max_h <= glob_check_sign * glob_h) then ( /* if number 10*/
omniout_str(always,"SETTING H FOR MAX H"),
glob_h : glob_check_sign * float_abs(glob_max_h),
glob_h_reason : 1,
found_h : true
)/* end if 10*/
) else (
found_h : true,
glob_h : glob_h * glob_check_sign
)/* end if 9*/
,
/* END OPTIMIZE CODE */
if (glob_html_log) then ( /* if number 9*/
html_log_file : openw("entry.html")
)/* end if 9*/
,
/* BEGIN SOLUTION CODE */
if (found_h) then ( /* if number 9*/
omniout_str(always,"START of Soultion"),
/* Start Series -- INITIALIZE FOR SOLUTION */
array_x[1] : c(x_start),
array_x[2] : c(glob_h),
glob_next_display : c(x_start),
glob_min_pole_est : glob_larger_float,
glob_least_given_sing : glob_larger_float,
glob_least_ratio_sing : glob_larger_float,
glob_least_3_sing : glob_larger_float,
glob_least_6_sing : glob_larger_float,
order_diff : 1,
/* Start Series array_y */
term_no : 1,
while (term_no <= order_diff) do ( /* do number 1*/
array_y[term_no] : array_y_init[term_no] * expt(glob_h , c(term_no - 1)) / c(factorial_1(term_no - 1)),
term_no : term_no + 1
)/* end do number 1*/
,
rows : order_diff,
r_order : 1,
while (r_order <= rows) do ( /* do number 1*/
term_no : 1,
while (term_no <= (rows - r_order + 1)) do ( /* do number 2*/
it : term_no + r_order - 1,
if (term_no < ats_max_terms) then ( /* if number 10*/
array_y_higher[r_order,term_no] : array_y_init[it]* expt(glob_h , c(term_no - 1)) / (c(factorial_1(term_no - 1)))
)/* end if 10*/
,
term_no : term_no + 1
)/* end do number 2*/
,
r_order : r_order + 1
)/* end do number 1*/
,
current_iter : 1,
glob_clock_start_sec : elapsed_time_seconds(),
glob_clock_sec : elapsed_time_seconds(),
glob_iter : 0,
omniout_str(debugl," "),
glob_reached_optimal_h : true,
glob_optimal_clock_start_sec : elapsed_time_seconds(),
while ((glob_iter < glob_max_iter) and (glob_check_sign * array_x[1] < glob_check_sign * x_end ) and (((glob_clock_sec) - (glob_orig_start_sec)) < (glob_max_sec))) do ( /* do number 1*/
/* left paren 0001C */
if (reached_interval()) then ( /* if number 10*/
omniout_str(info," "),
omniout_str(info,"TOP MAIN SOLVE Loop")
)/* end if 10*/
,
glob_iter : glob_iter + 1,
glob_clock_sec : elapsed_time_seconds(),
track_estimated_error(),
atomall(),
track_estimated_error(),
display_alot(current_iter),
if (glob_look_poles) then ( /* if number 10*/
check_for_pole()
)/* end if 10*/
,
if (reached_interval()) then ( /* if number 10*/
glob_next_display : glob_next_display + glob_display_interval
)/* end if 10*/
,
array_x[1] : array_x[1] + glob_h,
array_x[2] : glob_h
/* Jump Series array_y */,
order_diff : 2,
/* START PART 1 SUM AND ADJUST */
/* START SUM AND ADJUST EQ =1 */
/* sum_and_adjust array_y */
/* BEFORE ADJUST SUBSERIES EQ =1 */
ord : 2,
calc_term : 1,
/* adjust_subseriesarray_y */
iii : ats_max_terms,
while (iii >= calc_term) do ( /* do number 2*/
array_y_higher_work[2,iii] : array_y_higher[2,iii] / expt(glob_h , c(calc_term - 1)) / c(factorial_3(iii - calc_term , iii - 1)),
iii : iii - 1
)/* end do number 2*/
,
/* AFTER ADJUST SUBSERIES EQ =1 */
/* BEFORE SUM SUBSERIES EQ =1 */
temp_sum : glob__0,
ord : 2,
calc_term : 1,
/* sum_subseriesarray_y */
iii : ats_max_terms,
while (iii >= calc_term) do ( /* do number 2*/
temp_sum : temp_sum + array_y_higher_work[ord,iii],
iii : iii - 1
)/* end do number 2*/
,
array_y_higher_work2[ord,calc_term] : temp_sum * expt(glob_h , c(calc_term - 1)) / c(factorial_1(calc_term - 1)),
/* AFTER SUM SUBSERIES EQ =1 */
/* BEFORE ADJUST SUBSERIES EQ =1 */
ord : 1,
calc_term : 2,
/* adjust_subseriesarray_y */
iii : ats_max_terms,
while (iii >= calc_term) do ( /* do number 2*/
array_y_higher_work[1,iii] : array_y_higher[1,iii] / expt(glob_h , c(calc_term - 1)) / c(factorial_3(iii - calc_term , iii - 1)),
iii : iii - 1
)/* end do number 2*/
,
/* AFTER ADJUST SUBSERIES EQ =1 */
/* BEFORE SUM SUBSERIES EQ =1 */
temp_sum : glob__0,
ord : 1,
calc_term : 2,
/* sum_subseriesarray_y */
iii : ats_max_terms,
while (iii >= calc_term) do ( /* do number 2*/
temp_sum : temp_sum + array_y_higher_work[ord,iii],
iii : iii - 1
)/* end do number 2*/
,
array_y_higher_work2[ord,calc_term] : temp_sum * expt(glob_h , c(calc_term - 1)) / c(factorial_1(calc_term - 1)),
/* AFTER SUM SUBSERIES EQ =1 */
/* BEFORE ADJUST SUBSERIES EQ =1 */
ord : 1,
calc_term : 1,
/* adjust_subseriesarray_y */
iii : ats_max_terms,
while (iii >= calc_term) do ( /* do number 2*/
array_y_higher_work[1,iii] : array_y_higher[1,iii] / expt(glob_h , c(calc_term - 1)) / c(factorial_3(iii - calc_term , iii - 1)),
iii : iii - 1
)/* end do number 2*/
,
/* AFTER ADJUST SUBSERIES EQ =1 */
/* BEFORE SUM SUBSERIES EQ =1 */
temp_sum : glob__0,
ord : 1,
calc_term : 1,
/* sum_subseriesarray_y */
iii : ats_max_terms,
while (iii >= calc_term) do ( /* do number 2*/
temp_sum : temp_sum + array_y_higher_work[ord,iii],
iii : iii - 1
)/* end do number 2*/
,
array_y_higher_work2[ord,calc_term] : temp_sum * expt(glob_h , c(calc_term - 1)) / c(factorial_1(calc_term - 1)),
/* AFTER SUM SUBSERIES EQ =1 */
/* END SUM AND ADJUST EQ =1 */
/* END PART 1 */
/* START PART 2 MOVE TERMS to REGULAR Array */
term_no : ats_max_terms,
while (term_no >= 1) do ( /* do number 2*/
array_y[term_no] : array_y_higher_work2[1,term_no],
ord : 1,
while (ord <= order_diff) do ( /* do number 3*/
array_y_higher[ord,term_no] : array_y_higher_work2[ord,term_no],
ord : ord + 1
)/* end do number 3*/
,
term_no : term_no - 1
)/* end do number 2*/
/* END PART 2 HEVE MOVED TERMS to REGULAR Array */
)/* end do number 1*/
,/* right paren 0001C */
omniout_str(always,"Finished!"),
if (glob_iter >= glob_max_iter) then ( /* if number 10*/
omniout_str(always,"Maximum Iterations Reached before Solution Completed!")
)/* end if 10*/
,
if (elapsed_time_seconds() - (glob_orig_start_sec) >= (glob_max_sec )) then ( /* if number 10*/
omniout_str(always,"Maximum Time Reached before Solution Completed!")
)/* end if 10*/
,
glob_clock_sec : elapsed_time_seconds(),
omniout_str(info,"diff ( y , x , 1 ) = neg ( sin ( x ) ) - cos ( x ) ; "),
omniout_int(info,"Iterations ",32,glob_iter,4," ")
,
prog_report(x_start,x_end),
if (glob_html_log) then ( /* if number 10*/
logstart(html_log_file),
logitem_str(html_log_file,"2015-04-24T22:51:24-05:00")
,
logitem_str(html_log_file,"Maxima")
,
logitem_str(html_log_file,"sub_sin_cos")
,
logitem_str(html_log_file,"diff ( y , x , 1 ) = neg ( sin ( x ) ) - cos ( x ) ; ")
,
logitem_float(html_log_file,x_start)
,
logitem_float(html_log_file,x_end)
,
logitem_float(html_log_file,array_x[1])
,
logitem_float(html_log_file,glob_h)
,
logitem_h_reason(html_log_file)
,
logitem_str(html_log_file,"16")
,
logitem_float(html_log_file,glob_desired_digits_correct)
,
if (array_est_digits[1] # -16) then ( /* if number 11*/
logitem_integer(html_log_file,array_est_digits[1])
,
0
) else (
logitem_str(html_log_file,"Unknown")
,
0
)/* end if 11*/
,
if (glob_min_good_digits # -16) then ( /* if number 11*/
logitem_integer(html_log_file,glob_min_good_digits)
,
0
) else (
logitem_str(html_log_file,"Unknown")
,
0
)/* end if 11*/
,
if (glob_good_digits # -16) then ( /* if number 11*/
logitem_integer(html_log_file,glob_good_digits)
,
0
) else (
logitem_str(html_log_file,"Unknown")
,
0
)/* end if 11*/
,
logitem_str(html_log_file,"NA")
,
logitem_str(html_log_file,"NA")
,
logitem_integer(html_log_file,ats_max_terms)
,
if (glob_type_given_pole = 0) then ( /* if number 11*/
logitem_str(html_log_file,"Not Given")
,
logitem_str(html_log_file,"NA")
,
0
) elseif
(glob_type_given_pole = 4) then ( /* if number 12*/
logitem_str(html_log_file,"No Solution")
,
logitem_str(html_log_file,"NA")
,
0
) elseif
(glob_type_given_pole = 5) then ( /* if number 13*/
logitem_str(html_log_file,"Some Pole")
,
logitem_str(html_log_file,"????")
,
0
) elseif
(glob_type_given_pole = 3) then ( /* if number 14*/
logitem_str(html_log_file,"No Pole")
,
logitem_str(html_log_file,"NA")
,
0
) elseif
(glob_type_given_pole = 1) then ( /* if number 15*/
logitem_str(html_log_file,"Real Sing")
,
logitem_float(html_log_file,glob_least_given_sing)
,
0
) elseif
(glob_type_given_pole = 2) then ( /* if number 16*/
logitem_str(html_log_file,"Complex Sing")
,
logitem_float(html_log_file,glob_least_given_sing)
,
0
)/* end if 16*/
,
if (glob_least_ratio_sing < glob_large_float) then ( /* if number 16*/
logitem_float(html_log_file,glob_least_ratio_sing)
,
0
) else (
logitem_str(html_log_file,"NONE")
,
0
)/* end if 16*/
,
if (glob_least_3_sing < glob_large_float) then ( /* if number 16*/
logitem_float(html_log_file,glob_least_3_sing)
,
0
) else (
logitem_str(html_log_file,"NONE")
,
0
)/* end if 16*/
,
if (glob_least_6_sing < glob_large_float) then ( /* if number 16*/
logitem_float(html_log_file,glob_least_6_sing)
,
0
) else (
logitem_str(html_log_file,"NONE")
,
0
)/* end if 16*/
,
logitem_integer(html_log_file,glob_iter)
,
logitem_time(html_log_file,(glob_clock_sec))
,
if (c(glob_percent_done) < glob__100) then ( /* if number 16*/
logitem_time(html_log_file,(glob_total_exp_sec))
,
0
) else (
logitem_str(html_log_file,"Done")
,
0
)/* end if 16*/
,
log_revs(html_log_file," 308.maple.seems.ok | ")
,
logitem_str(html_log_file,"sub_sin_cos diffeq.max")
,
logitem_str(html_log_file,"sub_sin_cos maxima results")
,
logitem_str(html_log_file,"OK")
,
logend(html_log_file)
)/* end if 15*/
,
if (glob_html_log) then ( /* if number 15*/
close(html_log_file)
)/* end if 15*/
)/* end if 14*/
/* END OUTFILEMAIN */
)
)$ /* End Function number12 */
/* Begin Function number 13*/
main() := (
glob_iolevel : 2,
compile(all),
main_prog()
)$ /* End Function number13 */
main()$