Why are these BVH split heuristic formulas different?

I’ve been doing some research into changing the split heuristic I use for a work project comprised of a BVH binary tree.

The heuristic I currently use is centroid median as described here, but I seek to use the surface area heuristic (SAH) now. Several papers denote the cost function for determining the split as:

$ $ c(A, B) = t_{trav} + p_{A}\sum_{i=1}^{N_{A}}t_{isect}(a_{i}) + p_{B}\sum_{i=1}^{N_{B}}t_{isect}(b_{i})$ $

Notionally it is described in detail here, but to summarize, it is the cost of a ray intersect of primitives at this split.

However, I’ve seen an optimization technique, described as "binning", where $ K$ pre-determined bins are computed and therefore the cost function for determining the split is:

$ $ c(A, B) = A_{a}N_{a} + A_{b}N_{b}$ $

This is outlined here in Section 3.1, as well is several other documents (1, 2, 3).

What’s the rational/reasoning behind these two different cost models?

How many clauses are required for SAT to be NP-hard in CNF formulas?

It is not hard to see that SAT for a CNF formula with $ n$ variables and a constant number of clauses can be solved in polynomial time. On the other hand, it is not hard to see that a CNF formula with $ n$ variables and $ O(n)$ clauses is enough for NP-hardness (consider for example the instances of SAT associated with the natural formula for 3-colorability, applied to planar graphs).

We could define this formally as $ \text{CNFSAT}-f-\text{Clauses}$ , a family of problems parameterized by a function $ f$ , in which instances are formulas in CNF such that if they have $ n$ variables, then they have at most $ f(n)$ clauses. Based on this, what I’d like to know is what is the smallest function $ g$ such that we know there exists $ f \in O(g)$ such that $ \text{CNFSAT}-f-\text{Clauses}$ is already NP-hard. We know that g = 1 (constant # of clauses) does not work, and $ g = n$ (linear number of clauses) works.

What about $ g = \log n$ ? Is there a simple algorithm for CNFSAT over formulas that have $ O(\lg \lg n)$ clauses?

Circuits and formulas for Clique

Is it correct to say that the Clique Problem is in $ P$ iff there exists a family of Boolean circuits $ C$ to decide Clique whose sizes are bounded by a polynomial? And based on this question, does that imply that there exists an equivalent set of Boolean formulas $ F$ to decide Clique whose sizes are bounded by a polynomial? And if there is such an $ F$ , would there be correct derivations based on propositional logic axioms from any member of $ F$ to the corresponding large naive formula for Clique?

building a polynomial algorithm that solves SAT when given a polynomial TM that solves SAT on two formulas

Here’s the question:

Assume there exists a polynomial time machine $ M$ that receives two formulas $ \varphi_1,\varphi_2$ and satisfies the following:

  • If $ \varphi_1 \in \mathrm{SAT}$ and $ \varphi_2 \notin \mathrm{SAT}$ , then $ M(\varphi_1,\varphi_2)=1$
  • If $ \varphi_1 \notin \mathrm{SAT}$ and $ \varphi_2 \in \mathrm{SAT}$ , then $ M(\varphi_1,\varphi_2)=0$

Show that there also exists a polynomial time algorithm for SAT.

Note that we have no guarantee for the output of $ M(\varphi_1,\varphi_2)$ whenever $ \varphi_1,\varphi_2$ are both satisfiable (or when both are not).

Can I get any hint on how to start the solution?

How can I index and search a set of mathematical formulas? (using MathWebSearch or similar systems) [closed]

I have a bunch of documents and I need to search Mathematical Formulas in those documents. Those formulas must be ranked in a similar way Google ranks web pages.

Through Google I have found the open source system MathWebSearch but there is no good documentation of tht system.

Is there anybody here who already have worked with MathWebSearch and can help me using MathWebSearch?

Python – Paradigm to compute different formulas with the same function

I have different equations to compute the same quantity. For example, val = my_func(a, b, c) but also val = my_func(x, y), where my_func represents the quantity I would like to compute: it could be Velocity or Momentum or something completely different. I have dozens of quantities to code, each with multiple equations.

It is also essential that I provide a decent documentation for the different input arguments.

EDIT: I believe the end users of the code will be smart enough to use some kind of advanced editor with autocompletion and capable of displaying docstrings.

So far, I have thought about three basic approaches.

Approach #1: I can write one function for each equation.
Pros: easy to write.
Cons: From a developer standpoint it may be difficult to maintain the code as it grows. From a user standpoint it becomes “cumbersome”, in the sense that the user is forced to look at the correct function that accepts its arguments.

def my_func_1(a, b, c):     """     Compute my_func.      Parameters     ----------         a : float             blablabla         b : float             blablabla         c : float             blablabla     """     return a + b + c  def my_func_2(x, y):     """     Compute my_func.      Parameters     ----------         x : float             blablabla         y : float             blablabla     """              return x * y 

Approach #2: I can write one function accepting keywords arguments and manage all the different cases!
Pros: Easy to use from a user standpoint (the user only need to read the documentation of one function and insert the correct parameters).
Cons: From a developer standpoint (in my opinion) it requires a little bit more attention to what you are coding. From a user standpoint, it becomes a little bit harder to use as he/she is forced to use the keyword approach, for example: my_func(x=my_x_val, y=my_y_val).

def my_func(**args):     """     Compute my_func. Formulas:         (1) val = my_func(a, b, c)         (2) val = my_func(x, y)      Please, provide input parameters accordingly to the equation      you desire to solve.      Parameters     ----------         a : float             blablabla         b : float             blablabla         c : float             blablabla         x : float             blablabla         y : float             blablabla     """      if all(k in args for k in ["a", "b", "c"]):         a, b, c = args["a"], args["b"], args["c"]         return a + b + c     if all(k in args for k in ["x", "y"]):         x, y = args["x"], args["y"]         return x * y      raise ValueError("The given arguments can't be used to compute the " +          "my_func. Please, read the function docs.") 

Approach #3: I can write one function accepting a index argument associated to the equation the user would like to solve. This function return the correct equation (function) and the user insert the different arguments.
Pros: Easy to use from a user standpoint as there is no need for keywords arguments! For example, my_val = my_func(2)(my_x_val, my_y_val).
Cons: From a user standpoint it would be a good idea to also have a copy of the arguments description in the parent function docstring, but this would insert a lot of repetition in the comments, hence increase difficulty in maintaining the code.

def my_func(idx):     """     Compute my_func. Formulas:         (1) val = my_func(1)(a, b, c)         (2) val = my_func(2)(x, y)      Please, insert the index of the formulas you would like to solve.     """      if idx == 1:         def func(a, b, c):             """             Parameters             ----------                 a : float                     blablabla                 b : float                     blablabla                 c : float                     blablabla             """             return a + b + c         return func     if idx == 2:         def func(x, y):             """             Parameters             ----------                 x : float                     blablabla                 y : float                     blablabla             """             return x * y         return func      raise ValueError("The given index can't be used to compute the " +          "my_func. Please, read the function docs.") 

As of now, I would be inclined to use approach #2.

Is there any better paradigm for this problem? Do you happen to know some code that faced this problem?

how do I copy a table in Numbers 6.0 without losing the formulas?

Im using the newest version of numbers 6.0 and I’m looking for help on duplicating spreadsheets…I’m working on a custom monthly P&L and want to make a new one each month but do not want to lose all my formulas…but after I duplicate my sheet and go to clear the cells it not only clears the data sets it clears the formulas as well. I have read articles regarding creating a automation via utilities and storing under services and wasn’t sure this is the most up to date way of handing.

I did however try it and it worked but it also deleted every last cells information not just the ones I selected or the ones with formulas but even all my categories and such.

maybe there is another way? thanks in advance for any answers to this question!

Stacking multiple query formulas throws “an Array Literal was missing values for one or more rows”

I am attempting to run multiple queries where it adds rows where if F is blank, then it skips those rows, then runs the query again and replaces row F with row G.

I have a much more complicated formula doing the same thing but more variations, columns D(blank or not) – E and F(blank or not) – G

The following formula works

=SORT(ArrayFormula({  IFERROR(QUERY('6 Star Gear Sets (Hidden)'!A6:AA,   "select A, B, C, D, F, H, N, I, J, K, L, M     where A != ' ' AND D IS NOT NULL AND F IS NOT NULL order by F desc"));   IFERROR(QUERY('6 Star Gear Sets (Hidden)'!A6:AA,    "select A, B, C, E, F, H, N, I, J, K, L, M     where A != ' ' AND D IS NULL AND F IS NOT NULL order by F desc"));   IFERROR(QUERY('6 Star Gear Sets (Hidden)'!A6:AA,    "select A, B, C, D, G, H, N, I, J, K, L, M     where A != ' ' AND D IS NOT NULL AND F IS NULL order by F desc"));   IFERROR(QUERY('6 Star Gear Sets (Hidden)'!A6:AA,    "select A, B, C, E, G, H, N, I, J, K, L, M     where A != ' ' AND D IS NULL AND F IS NULL order by F desc"))  }),5,FALSE) 

But my more simple version of the same formula returns an error

=SORT(ArrayFormula({  IFERROR(QUERY('5 Star Clubs (Hidden)'!A6:Z,    "select A, B, C, D, E, F, H, I     where A != ' ' AND F IS NOT NULL"));   IFERROR(QUERY('5 Star Gear Clubs (Hidden)'!A6:Z,    "select A, B, C, D, E, G, H, I     where A != ' ' AND F IS NULL"))  }),7,FALSE) 

The error is: In ARRAY_LITERAL, an Array Literal was missing values for one or more rows.

A link to a copy of the google sheets is as follows:

https://docs.google.com/spreadsheets/d/1s6spmfCVP6P331Zr9xfE9kiei3Wly6FRQCdA8Y3e7tA/edit?usp=drivesdk.


Additional Question

UPDATED FORMULA of the original working formula

=SORT( ArrayFormula( { IFERROR( QUERY( '6 Star Gear Sets (Hidden)'!A6:AA, "select A, B, C, D, F, H, N, I, J, K, L, M where A != ' ' AND D IS NOT NULL AND F IS NOT NULL order by F desc"),{"","","","","","","",""}); IFERROR( QUERY( '6 Star Gear Sets (Hidden)'!A6:AA, "select A, B, C, E, F, H, N, I, J, K, L, M where A != ' ' AND D IS NULL AND F IS NOT NULL order by F desc"),{"","","","","","","",""}); IFERROR( QUERY( '6 Star Gear Sets (Hidden)'!A6:AA, "select A, B, C, D, G, H, N, I, J, K, L, M where A != ' ' AND D IS NOT NULL AND F IS NULL order by F desc"),{"","","","","","","",""}); IFERROR( QUERY( '6 Star Gear Sets (Hidden)'!A6:AA, "select A, B, C, E, G, H, N, I, J, K, L, M where A != ' ' AND D IS NULL AND F IS NULL order by F desc"),{"","","","","","","",""}) } ) ,5,FALSE,4,FALSE)

WORK AROUND

In the 6 Star Gear Sets (Hidden) sheet the formula references, there is a row with A column “zzzzz” and both F and G is blank. When this row is called using the above ArrayFormula, I use a Conditional Format to hide all rows with “zzzzz”.

QUESTION

If I remove the row with “zzzzz” in column A from the hidden sheet, I recieve an error.. why?

ADDITIONAL INFO

Breaking the formula into individual QUERY forumlas and removing IFERROR, shows the 3rd query is empty and returns #N/A error, but the 4th query also does not return any results and it does not give such an error. I figured the IFERROR statement would handle this but to no avail.

UPDATE

Found the 4th query isn’t returning empty. It is actually returning blank cells. Which again, adds to the list of questions. Because I have the IFERROR function removed and where A != ' ' I thought would handle this. Is that not Where A DOES NOT MATCH blank?

I’ve tried wrapping it in an IF(IFNA()) formula but I guess you can’t use IFNA outside Conditional Formatting because it says IFNA() isn’t a known function.

UPDATE 2

For some reason I immediately forgot the part about the number of blank arguments in the IFERROR statement needs to match the number of columns being referenced.

However, =SORT is no longer working correctly as there is now a blank row at the top of the new table and I still do not have a good explanation of why the 4th Query is filling the table with blank rows.

UPDATE 3

In the A column of my “6 Star Gear Sets” sheet, I have a formula that numbers everything in the order they appear unless the B column is blank. For some reason, the blank row that is inserted due to the =IFERROR(,) isn’t actually being treated as being blank.

In additional, my =SORT orders everything in descending order by the F and then E column. However, it treats the F and E in the inserted blank row as the highest value row.

UPDATED FORMULA

=SORT( ArrayFormula( { IFERROR( QUERY( '6 Star Gear Sets (Hidden)'!A6:AA, "select A, B, C, D, F, H, N, I, J, K, L, M where A != ' ' AND D IS NOT NULL AND F IS NOT NULL order by F desc"),{"","","","","","","","","","","",""}); IFERROR( QUERY( '6 Star Gear Sets (Hidden)'!A6:AA, "select A, B, C, E, F, H, N, I, J, K, L, M where A != ' ' AND D IS NULL AND F IS NOT NULL order by F desc"),{"","","","","","","","","","","",""}); IFERROR( QUERY( '6 Star Gear Sets (Hidden)'!A6:AA, "select A, B, C, D, G, H, N, I, J, K, L, M where A != ' ' AND D IS NOT NULL AND F IS NULL order by F desc"),{"","","","","","","","","","","",""}); IFERROR( QUERY( '6 Star Gear Sets (Hidden)'!A6:AA, "select A, B, C, E, G, H, N, I, J, K, L, M where A != ' ' AND D IS NULL AND F IS NULL order by F desc"),{"","","","","","","","","","","",""}) } ) ,5,FALSE,4,FALSE)

UPDATED LINK

Below is an updated copy of my spreadsheet.

https://docs.google.com/spreadsheets/d/17Ev1_Scobnl16H9TuTrHK_es7fZGkMqHyvmpWWWVbow/edit?usp=drivesdk

How many isomorphic 3SAT formulas?

For a 3SAT formula with $ n$ variables and $ m$ clauses, I am interested in counting the number of isomorphic formulas (isomorphic in the sense that they are logically equivalent and have the same number of variables and clauses). I assume that we can invert the sense of any variable (swap all $ x_i$ with $ \lnot x_i$ ) and permute any of the variables. The first should give $ 2^n$ and the second should give $ n!$ .

Is this all of the isomorphisms, or am I overlooking anything?

If this is correct, then I assume that the number of distinct 3SAT formulas with $ n$ variables and “distinct clauses” is equal to $ \frac{2^m}{2^nn!}$ , where $ m$ is the number of 3-clauses over $ n$ variables in which all variables are distinct. I assume that $ m=2n(2n-2)(2n-4)$ . Does that sound right?