inverses for •math.Atan2, •math error tests

This commit is contained in:
dzaima 2023-10-22 14:28:57 +03:00
parent 1ec48bb761
commit 577442449d
3 changed files with 25 additions and 8 deletions

View File

@ -21,10 +21,11 @@
/*internal.c*/D(eequal,"•internal.EEqual") M(squeeze,"•internal.Squeeze") M(deepSqueeze,"•internal.DeepSqueeze") \
/*internal.c*/A(internalTemp,"•internal.Temp") M(iHasFill,"•internal.HasFill") M(iKeep,"•internal.Keep") \
/*internal.c*/D(variation,"•internal.Variation") A(listVariations,"•internal.ListVariations") M(clearRefs,"•internal.ClearRefs") M(unshare,"•internal.Unshare") \
/* arithm.c*/M(sin,"•math.Sin") M(cos,"•math.Cos") M(tan,"•math.Tan") M(asin,"•math.Asin") M(acos,"•math.Acos") M(atan,"•math.Atan") D(atan2,"•math.Atan2") D(hypot,"•math.Hypot") \
/* atithd.c*/D(hypot,"•math.Hypot") D(comb,"•math.Comb") D(gcd,"•math.GCD") D(lcm,"•math.LCM") D(atan2,"•math.Atan2") D(atan2ix,"•math.Atan2⁼") D(atan2iw,"•math.Atan2˜") \
/* arithm.c*/M(sin,"•math.Sin") M(cos,"•math.Cos") M(tan,"•math.Tan") M(asin,"•math.Asin") M(acos,"•math.Acos") M(atan,"•math.Atan") \
/* arithm.c*/M(sinh,"•math.Sinh") M(cosh,"•math.Cosh") M(tanh,"•math.Tanh") M(asinh,"•math.Asinh") M(acosh,"•math.Acosh") M(atanh,"•math.Atanh") \
/* arithm.c*/M(cbrt,"•math.Cbrt") M(log2,"•math.Log2") M(log10,"•math.Log10") M(log1p,"•math.Log1p") M(expm1,"•math.Expm1") M(fact,"•math.Fact") D(comb,"•math.Comb") M(logfact,"•math.LogFact") \
/* arithm.c*/M(erf,"•math.Erf") M(erfc,"•math.ErfC") D(gcd,"•math.GCD") D(lcm,"•math.LCM") M(sum,"•math.Sum")
/* arithm.c*/M(cbrt,"•math.Cbrt") M(log2,"•math.Log2") M(log10,"•math.Log10") M(log1p,"•math.Log1p") M(expm1,"•math.Expm1") M(fact,"•math.Fact") M(logfact,"•math.LogFact") \
/* arithm.c*/M(erf,"•math.Erf") M(erfc,"•math.ErfC") M(sum,"•math.Sum")
#define FOR_PM1(A,M,D) \
/* md1.c*/A(tbl,"") A(each,"¨") A(fold,"´") A(scan,"`") A(const,"˙") A(swap,"˜") A(cell,"˘") A(insert,"˝") \

View File

@ -470,14 +470,19 @@ static f64 comb(f64 k, f64 n) { // n choose k
}
return exp(lgamma(n+1) - lgamma(k+1) - lgamma(j+1));
}
static f64 bqn_atan2(f64 w, f64 x) { return atan2(w+0, x+0); }
static f64 bqn_atan2 (f64 x, f64 w) { return atan2(x+0, w+0); }
static f64 bqn_atan2ix(f64 x, f64 w) { return w * tan(x); }
static f64 bqn_atan2iw(f64 x, f64 w) { return w / (tan(x)+0); }
#define MATH(n,N,I) B n##_c2(B t, B w, B x) { \
if (isNum(w) && isNum(x)) return m_f64(I(x.f, w.f)); \
P2(n) \
thrM("•math." #N ": Unexpected argument types"); \
thrM("•math." N ": Unexpected argument types"); \
}
MATH(atan2,Atan2,bqn_atan2) MATH(hypot,Hypot,hypot) MATH(comb,Comb,comb)
MATH(atan2,"Atan2",bqn_atan2)
MATH(atan2ix,"Atan2⁼",bqn_atan2ix)
MATH(atan2iw,"Atan2˜",bqn_atan2iw)
MATH(hypot,"Hypot",hypot) MATH(comb,"Comb",comb)
#undef MATH
static u64 gcd_u64(u64 a, u64 b) {
@ -522,5 +527,6 @@ B lcm_c2(B t, B w, B x) {
#undef P2
void arithd_init() {
c(BFn, bi_atan2)->iw = atan2iw_c2;
c(BFn, bi_atan2)->ix = atan2ix_c2;
}

View File

@ -179,10 +179,20 @@ t0←•MonoTime@ ⋄ ! 0.1≤•Delay 0.1 ⋄ ! 0.1≤(•MonoTime@)-t0
! {(0 •math.Atan2 𝕩) (•ParseFloat"-0") •math.Atan2 𝕩} (-) ˜3
E•internal.EEqual a(¯1×) (3)0÷0 {𝕩!(a 𝕏 0)E a 𝕏 •ParseFloat"-0" 𝕩!(0 𝕏 a)E(•ParseFloat"-0") 𝕏 a}¨ ({𝕏¨}¨) +,-,×,÷,,,,,|,¬,,,<,>,,=,,, •math.Atan2,•math.Comb,•math.Hypot
E•internal.EEqual {! (𝕏 40) E 𝕏 1¯1×π40}¨ ({𝕏¨}¨) +,-,×,÷,,,,,|,¬, •math.Sin,•math.Cos,•math.Tan,•math.Asin,•math.Acos,•math.Atan,•math.Sinh,•math.Cosh,•math.Tanh,•math.Asinh,•math.Acosh,•math.Atanh,•math.Cbrt,•math.Log2,•math.Log10,•math.Log1p,•math.Expm1,•math.Fact,•math.LogFact,•math.Erf,•math.ErfC
•internal.EEqual´¨ 1˘¨{•math.Atan22𝕩, •math.Atan20𝕩, 2•math.Atan2𝕩, 0•math.Atan2𝕩} (¯1×) 1.20 %% 1111
{15 𝕏 10}¨ •math.GCD,•math.LCM %% 530
1e5×{0.1 𝕏 0.2}¨ •math.Atan2,•math.Comb,•math.Hypot %% 1107149695922360
1e5×{0.1 𝕏 0.2}¨ •math.Atan2,•math.Comb,•math.Hypot,•math.Atan2,•math.Atan2˜ %% 1107149695922360202749331
1e5×{=˜99¨ 𝕏 0.13}¨ •math.Acos,•math.Acosh,•math.Asin,•math.Asinh,•math.Atan,•math.Atanh,•math.Cbrt,•math.Cos,•math.Cosh,•math.Erf,•math.ErfC,•math.Expm1,•math.Fact,•math.Log10,•math.Log1p,•math.Log2,•math.LogFact,•math.Sin,•math.Sinh,•math.Tan,•math.Tanh %% 1470629900000,9900000176274,100169900000,9983181844,9966124904,100339900000,46415144224,99500¯99000,1005001006766,1124699997,887532,105171908553,95135600000,¯10000047712,9531138629,¯332193158496,¯4988179175,998314112,100161001787,10033¯14255,996699505
!"•math.GCD: Inputs other than natural numbers not yet supported" % 1.5 •math.GCD 3
!"•math.LCM: Inputs other than natural numbers not yet supported" % 3 •math.LCM 1.5
!"•math.GCD: Unexpected argument types" % "foo" •math.LCM 3
!"•math.GCD: Unexpected argument types" % 3 •math.GCD {+}
!"•math.Sin: Argument contained non-number" % •math.Sin "foo"
!"•math.Log10: Argument contained non-number" % •math.Log10 "foo"
!"•math.Atan2: Unexpected argument types" % 1 •math.Atan2 'a'
!"•math.Atan2⁼: Unexpected argument types" % 1 •math.Atan2 {}
!"•math.Atan2˜⁼: Unexpected argument types" % {} •math.Atan2˜ 'b'
# •rand / •MakeRand
0 (•MakeRand 0).Range¨2 %%