Clear variables on window close

I’m using

DynamicModule[{ var1, var2 },  CreateDialog[ (*some code here*) ]] 

In order to be able to deal with memory isolation for multiple copies of a program running at once. Is there an option to use in CreateDialog to run a command upon the closing of that Dialog? When that window gets closed I would like to clear all the variables to free up the memory.

Use global variables with Elementor page builder

I have created a short code with php and widget for sidebar to control the results of the short code I made and I need to use some global variables to send from the short code to the sidebar widget, everything working fine, But when I am using Elementor page builder global variables disappears!! However when using another page builder everything working well!! any help about that as I wish to use Elementor in my site! Cheers Mo

Compile function with only some variables

I made the simple example below for explaining the problem. How can I compile only some variables?
For example, in the example only a and b are Integer, c can be any type.

In[218]:= cf = Compile[{{a, _Integer}, {b, _Integer}, c}, a*b + c]; cf[2, 3, d] CompiledFunction::cfsa: Argument d at position 3 should be a machine-size real number. Out[219]= 6 + d 

How can I solve this warning and make this work for any c?
I want "c" to be anything.

Specifying statistical models / Equations between Random Variables

I’m new to Mathematica and confused about how random variables work.

Say I have a standard normal random variable $ X\sim \mathcal N(0,1)$ and set $ Y := 2X$ . Then $ \operatorname{Cov}(X,Y) = 2$ . Now if I generate $ N$ -iid. draws for $ X$ , the sample covariance of $ X_1,\dots, X_N$ and $ Y_1,\dots, Y_N$ with $ Y_n := 2X_n$ should be close to $ 2$ .

My question is: how can I compute statistics (e.g. sample covariance) in Mathematica? Naively, I tried

x:=RandomVariate[NormalDistribution[], 5000] y:=2*x Covariance[x,y] 

but the result is clearly incorrect (usually not close to $ 2$ ), because in actuality (I presume) under this model $ Y$ is independent of $ X$ .

What is the most convenient way of achieving the correct result?

Solving trigonometric equations with two variables in fixed range?

I am trying to use ‘Solve’ function to solve two trigonometric equations with two variables a1 and a2 (with range 0,2Pi). I wrote the code in the following:

  Vets={Cos[2a1](I+Cos[2a2])+Sin[2a1]Sin[2a2], (I-Cos[2a2])Sin[2a1]+Cos[2a1]Sin[2a2]};   Solve[Vets[[1]] == 1 && Vets[[2]] == 0 && 0<=a1<=2Pi && 0<=a2<=2Pi, {a1,a2}]  

but it gives errors:

Solve::nsmet: This system cannot be solved with the methods available to Solve.

I looked up the documents for Solve function and it should be no problem with the above code. But it doesn’t do anything and give errors, I don’t understand why?

It will be super cool if anyone could answer this question, thank you very much in advance!

How to safely change Innodb variables

I’m using Maria DB, version 10.2.22, where one database column uses FULLTEXT for a broad document searching. However, I’ve ran into a "Table handler out of memory" on some searches. The table itself is only 4.4 GB. I’ve read on stackoverflow, that changing some of the InnoDB variables such as:

• innodb_buffer_pool_size

• innodb_ft_result_cache_limit

from their default value to say 4 GB could potential solve to the memory issue. My question is three parts, I suppose.

  1. Are there any other variables I should consider changing.

• innodb_buffer_pool_instances
• innodb_ft_cache_size
• innodb_ft_total_cache_size

  1. Because this DB is fairly critical to run, after running the command lines to change the variables would I need to stop and start the MariaDB service to fetch these changes?

  2. If, restarting MariaDB services is needed, can anyone point me to a guide as far as how to safely change these variables?

Maximize an expression with respect to a variable and minimize it with respect to other variables

I started to use Mathematica a few time ago. I want to minimize the following expression (function of $ l,p,q,r,c$ ) with respect to variables $ l, p, q, r$ and then maximize the result obtained with respect to variable $ c$ . However, when I try to obtain an expression function of $ c$ to maximize later using Minimize, I do not get any result because it takes too long. How can I solve this issue?

Minimize[{(((l^2/2)*(1-(1/4-c))+(l*p)*(1-1/4)+(l*q)*(1-(1/4+c))+(l*r)*(1-1/2)+(p^2/2)*(1-c)+(p*q)*(1-2*c)+(p*r)*(1-(1/4+c))+(q^2/2)*(1-c)+(q*r)*(1-1/4)+(r^2/2)*(1-(1/4-c)))/((l^2/2)*(1-(1/4-c))+(l*p)*(1-1/4)+(l*q)*(1-(1/4-c))+(l*r)*(1-0)+(p^2/2)*(1-c)+(p*q)*(1-(1/4-c))+(p*r)*(1-0)+(q^2/2)*(1-(1/4-c))+(q*r)*(1-1/4)+(r^2/2)*(1-0))), l >= 1, p >= 0, q >= 0, r >= 0, l + p + q + r == 1000000, 1/7<c<1/5}, {l, p, q, r}] 

UPDATE with variables to renumber column gives syntax error

Searching for a way to renumber a column within mysql, I’ve found multiple articles showing the same approach:

  • Renumbering an Ordering Field in MySQL
  • How to update a MySql column with ascending numbers

among others.

But trying it on my table I get a syntax error.

mysql> SET @rankStart = 10; mysql> SET @rankInc = 10; mysql> UPDATE fileFileTbl SET rank = (@rankStart := @rankStart + @rankInc) ORDER BY `rank` ASC; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'rank = (@rankStart := @rankStart + @rankInc) ORDER BY `rank` ASC' at line 1 

The command looks identical to the articles posted. What am I missing?

Here’s the table (with some columns omitted):

CREATE TABLE `fileFileTbl` (   `id` int(11) unsigned NOT NULL AUTO_INCREMENT,   `fileEngineId` int(11) DEFAULT NULL,   `rank` int(11) DEFAULT '0',   `fileName` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT 'newfile',   PRIMARY KEY (`id`),   UNIQUE KEY `fileEngineId` (`fileEngineId`,`rank`) ) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8; 

System is Centos 8, with mysql as:

# mysql --version mysql  Ver 8.0.17 for Linux on x86_64 (Source distribution) 

SAT satisfaction with 10 variables

I am trying to prove that the next problem is NPC:

$ A=$ {$ <\phi>|\phi \,\,\,is\,\,\,a\,\,\,CNF\,\,\,and\,\,\,has\,\,\,satisfying\,\,\,assignment\,\,\,where\,\,\,exactly\,\,\,10\,\,\,variables\,\,\,are\,\,\,TRUE$ }

I am trying to find polynomial mapping reduction from SAT but I can’t find a way to force exactly 10 variables to get TRUE assignment. My idea was to create new formula, with 10 clauses, each clause is the intersection of a new variable $ x_i$ with the old formula, but I don’t see how my idea helpful.

I would appreciate help.