So let’s say we have the function $f(n)$ that gives $k$ such that $k$ is the smallest number that gives a busy beaver function $B$ value from input $k$ that is greater than $n$. Or more succinctly the smallest $k$ with $B(k) > n$. Can there be computable functions that are not in time complexity class $O(n^c)$ for some constant $c$ but that are in $O(n^{f(n)})$. And by extension, is it true that $P = O(n^{f(n)})$?

# Tag: functions

## macbook pro – My Touchbar isn’t responding. If I tap, it works but im not able to view the functions. How can I solve this problem?

## co.combinatorics – Factoring multi-variable functions over monoids

This is a follow-up question to this MO question, which was asked by Richard Stanley in a comment to my answer there.

Let $S$ be a commutative monoid and $f(x_1, dots, x_n)$ be a function from $S^n$ to $S$. Given a partition $alpha$ of $(n)$, we say that $f$ *factors with respect to $alpha$*, if for each $A in alpha$ there exists a function $f_A$ (which only depends on the variables $x_i$ for $i in A$) such that $f=prod_{A in alpha} f_A$. Given two partitions $alpha$ and $beta$ of $(n)$, $a wedge b$ is the partition of $(n)$ whose sets are the non-empty sets of the form $A cap B$ for $A in alpha$ and $B in beta$.

Question.Is it true that if $f$ factors with respect to both $alpha$ and $beta$, then $f$ also factors with respect to $alpha wedge beta$?

My answer to the linked question shows that the answer is **yes** if $S$ is a group, but the proof uses the fact that inverses exist. My proof also works for non-abelian groups (as long as you are careful what factoring means), but for this question I am happy to assume that $S$ is commutative.

## equation solving – How can I get a numerical solution with Bessel functions?

```
Clear("Global`*")
eqn(t_) = x BesselJ(1, x) == t BesselJ(0, x);
```

As suggested by user64494, for a given `t`

, constrain `x`

to an interval. However, use `Solve`

```
Solve({eqn(0), -15 < x < 15}, x) // N // Quiet
(* {{x -> 0.}, {x ->
0.}, {x -> -13.3237}, {x -> -10.1735}, {x -> -7.01559}, {x -> -3.83171},
{x -> 3.83171}, {x -> 7.01559}, {x -> 10.1735}, {x -> 13.3237}} *)
```

Note that `NSolve`

may miss a solution

```
NSolve({eqn(0), -15 < x < 15}, x)
(* {{x -> -13.3237}, {x -> -10.1735}, {x -> -7.01559}, {x -> -3.83171}, {x ->
3.83171}, {x -> 7.01559}, {x -> 10.1735}, {x -> 13.3237}} *)
```

Use `ContourPlot`

to see the solutions

```
cp = ContourPlot(Evaluate@eqn(t),
{x, -15, 15}, {t, -5, 5},
FrameLabel -> (Style(#, 12, Bold) & /@ {x, t}));
Manipulate(
t = Rationalize(tt, 0);
sol = x /. Solve({eqn(t), -15 < x < 15}, x) // Quiet;
Show(cp,
Graphics({Red, AbsolutePointSize(4),
Tooltip(Point({#, tt}), N@#) & /@ sol}),
ImageSize -> Medium),
{{tt, 0, "t"}, -5, 5, 0.1, Appearance -> "Labeled"},
SynchronousUpdating -> False)
```

## Is there a simple algorithm for generating unit tests given a function’s code?

Given the abstract syntax tree (AST) of each line of a function’s code, I am asked to generate code for that function’s corresponding unit tests, similar to what Microsoft’s IntelliTest tool does here: https://docs.microsoft.com/en-us/visualstudio/test/generate-unit-tests-for-your-code-with-intellitest?view=vs-2019.

The issue is that I have to **implement this from scratch** instead of using built-in tools, since my project is implementing an ABAP to C# interpreter (ABAP is a programming language used for SAP’s enterprise software), which executes ABAP code in C#, so I cannot just use an IDE’s unit test generation tool.

I so far have decided that the first part of the algorithm is to generate the function’s parameters, but I’m not sure how I’m going to generate the function’s parameters exactly. Furthermore, I don’t know how the unit test generator is going to compute the **expected outputs** of the function.

**Note**: This algorithm doesn’t need to be an algorithm that works as well as an IDE’s automatic unit test generation, I just need to be able to come up with an algorithm that is an initial working prototype. But so far, I am stumped, and haven’t found any good online resources regarding this topic.

## programming languages – Is there a simple algorithm for generating unit tests given a function’s code?

Given the abstract syntax tree (AST) of each line of a function’s code, I am asked to generate code for that function’s corresponding unit tests, similar to what Microsoft’s IntelliTest tool does here: https://docs.microsoft.com/en-us/visualstudio/test/generate-unit-tests-for-your-code-with-intellitest?view=vs-2019.

The issue is that I have to **implement this from scratch** instead of using built-in tools, since my project is implementing an ABAP to C# interpreter (ABAP is a programming language used for SAP’s enterprise software), which executes ABAP code in C#, so I cannot just use an IDE’s unit test generation tool.

I so far have decided that the first part of the algorithm is to generate the function’s parameters, but I’m not sure how I’m going to generate the function’s parameters exactly. Furthermore, I don’t know how the unit test generator is going to compute the **expected outputs** of the function.

**Note**: This algorithm doesn’t need to be an algorithm that works as well as an IDE’s automatic unit test generation, I just need to be able to come up with an algorithm that is an initial working prototype. But so far, I am stumped, and haven’t found any good online resources regarding this topic.

## Convex Sets and Conic Sets and Functions

It appears as though all convex sets are conic. But is every conic set convex? I can’t seem to think of an edge case where a conic set isn’t convex. Moreover, from the definition of a cone and conic combination:

From the definition of a cone:

Let $theta in R$ and $x in R^{n}$, $x in C implies theta x in C$.

From the definition of a conic combination

Let $theta_{1}, theta_{2}, …, theta_{n} in R$ and $x_{1}, x_{2}, …, x_{n} in R^{n}$, then the linear combination

$$tilde{x} = theta_{1}x_{1} + theta_{2}x_{2} + … + theta_{n}x_{n}$$ is a cone if $theta_{1}, theta_{2}, …, theta_{n} geq 0$.

Don’t these definitions encompass convex sets and convex hulls (restricting $sum_{i = 1}^{n}theta_{i} = 1$)?

## web browser – A runtime sometimes converts string arguments (or string returns) from WTF-16 to UTF-16 between functions in a call stack. Is this a security concern?

For example, suppose we have this code (in TypeScript syntax):

```
function one(str: string): string {
// do something with the string
return str
}
function two() {
let s = getSomeString() // returns some unknown string that may contain surrogates
s = one(s)
// ...
}
two()
```

Now suppose that when passing the string `s`

into the `one(s)`

call, the runtime (not the implementation of `one`

or `two`

will *sometimes* replace part of the string. In particular, this will happen when there are WTF-16 “isolated surrogates”, but the main idea here is that this is not common and most developers will not be aware that this happens… until it happens.

Now, suppose this never happened before, but the runtime recently added this format conversion between function calls (converting function arguments or their return values without the implementation of any function having a choice in the matter).

In such a runtime, could there be a security issue after the runtime has switched from never changing strings to now doing it sometimes? If so, what could happen?

In particular, the runtime I am thinking about is JavaScript interfacing with WebAssembly in the browser in the potential near future if the new “Interface Types” proposal passes a vote for string passing to have WTF-to-UTF sanitization.

What I could imagine, for example, is some third party library updating an implementation of one or more of their functions from JavaScript to WebAssembly, this in turn causing strings being passed from JS to WebAssembly (or vice versa) to be modified from their original form, causing unexpected errors, or in the worst case, a vulnerability.

Is there a potential problem here?

## How to plot a point in the intersection of two functions?

I’m trying to plot the intersection of a Sum function with a horizontal line and automatically highlight the intersection points.

The code below shows my knowledge of Mathematica and for different values of “d” I am calculating with Solve the intersection points (ex p1,p2 and p3) and manually typing the value in the Epilog option. I tried Point({p1,1}) but it doesn’t work. I also tried it with MeshFunctions -> {g(#) – f(#) &}, Mesh -> {{0}}, MeshStyle ->

PointSize(Large) but I get an error “functions must be pure functions”. I would also like to be able to define the ranges of “d” and “pc” as {d, {min,max,incr}} instead of a list.

Thanks in advance.

```
np = 2
f(pc_) := 1
q(d_, pc_) := (pc/(100*0.48)) *
Sum(((Pi/4)*(d - (2*n*0.48))^2), {n, 1, np})
p(d_) := Sum(Pi*(d - (2*n - 1)*0.48), {n, 1, np})
p1 = Solve(q(20, pc)/p(20) == f(pc), pc)
p2 = Solve(q(10, pc)/p(10) == f(pc), pc)
p3 = Solve(q(8, pc)/p(8) == f(pc), pc)
g(d_, pc_) := q(d, pc)/p(d)
Plot({Evaluate(Table(g(d, pc), {d, {8, 10, 20}})), f(pc)}, {pc, 0,
50}, PlotRange -> All, AxesLabel -> {"%", "li/lp"},
FrameLabel -> {Style("pc", 12, Bold), Style("li/lp", 12, Bold)},
PlotLabels -> {"d=8", "d=10", "d=20"}, PlotTheme -> "Scientific",
GridLines -> Automatic, PlotLabel -> "Razão comprimentos",
Epilog -> {PointSize(0.02), Point({10.6053, 1}), Point({23.6134, 1}),
Point({31.2426, 1})})
```

## formulas – Google sheets – how can I use functions to resort my table in a way charts can read it well

I’m using app sheets to see what I do in a day. I select the task I am starting on the app and app sheets dumps the data into a table in google sheets.

I have made an example of what this looks like. Sheet1 is what it looks like At the moment and sheet2 is what I would like it to look like (or something else that will help charts read it).

https://docs.google.com/spreadsheets/d/1GF6cjlNMSTJov4G6ZMusXSWS-DMwnK4SgQqNs8d8uws/edit?usp=sharing

I have been pulling my hair out trying to do this so if you know how please tell me.