## Writing mathematical expression in a file

I am trying to write a mathematical expression as variable = expression in the output file.

The current method that I am doing is through WriteString as

expr = -((a*b*y^2*(-1 + z)*z*(1 + a*b + z))/(1 + a*b)^2) +         (z*(1 + a*b - a*b*z + (z + a*b*z)^2))/(1 + a*b)^2 -         (y*z*((-1 + z)^2 + a*b*(2 - 3*z + z^2) + a^2*b^2*(1 - z + z^2)))/(1 + a*b)^2 expression = CForm[expr] /. {Power->pow}; (*expression = CForm[HornerForm[expr]] /. {Power->pow};*) str=OpenWrite["output.hh"]; WriteString[str," double variable = ", expression,";"]; (*WriteString[str," double variable = ", ExportString[expression,"Text"]];*) Close[str]; 

The output is

 cat output.hh  double variable = -(a*b*(-1 + z)*z*(1 + a*b + z)*pow(1 + a*b,-2)*pow(y,2)) - y*z*pow(1 + a*b,-2)*(pow(-1 + z,2) + a*b*(2 - 3*z + pow(z,2)) + pow(a,2)*pow(b,2)*(1 - z + pow(z,2))) + z*pow(1 + a*b,-2)*(1 + a*b - a*b*z + pow(z + a*b*z,2)); 

I want to break the line as the original expr (or after some user-specified column say 80) i.e.

 double variable = -(a*b*(-1 + z)*z*(1 + a*b + z)*pow(1 + a*b,-2)*pow(y,2)) -                    y*z*pow(1 + a*b,-2)*(pow(-1 + z,2) + a*b*(2 - 3*z + pow(z,2)) + pow(a,2)*pow(b,2)*(1 - z + pow(z,2))) +                     z*pow(1 + a*b,-2)*(1 + a*b - a*b*z + pow(z + a*b*z,2)); 

Although this might not lead to optimized expression for numerical evaluation, however it is wanted as beautification. Also how should one optimize expression for further processing to other languages. Any suggestion? ExperimentalOptimizeExpression and HornerForm are some options. Any other recommendation? MathCode is much costly 😀

## Plugin For Schema Writing in WordPress

I have started writing a blog, and I have superb content. I want to optimize the blog and Schema is necessary for it. I had searched for some WordPress plugins for it. But, unable to find any worth finding give me some suggestion for it.

## Is it ok to use the type of monsters in table top RPG for commercial use in writing?

Some types like "Vampire" are obviously public domain but what about the more obscure ones like "Duergar", "Drow", "Boggards", etc. Are these also public domain?

How can you tell if it’s not public domain?

## Like the title says:

How do I edot this texconv "IMGtoBC3.bat" file so it "READS FROM & PRESERVES the directory structure when writing the "resulting" dds files?

I have a large folder/sub-folders with many tiff’s that "have the same file name" divided up into "sets".

These dds files are for custom textures in a unity game, file naming is a forced event, but "sorted/selected" by folder.

I have about 3000 file sets ready to convert and I’m not doing them 1 by 1 in Nvidia tool (I hope) and AMD tool and the game have a MAJOR conflict (its as a no go)

BONUS points to anyone that could show me this "bat" file using unity’s new tree of "CRUNCH" cmd line dds compressor/encoder. Suggestions of other tools: I have tested over 50 apps, for my needs its: Nvidia, texconv and then crunch in level of quality/support

ECHO OFF Setlocal EnableDelayedExpansion  ::Variables SET @FORMAT=BC3_UNORM SET @InputFolder=%~dp0Input_IMG_TO_BC3\ SET @OutputFolder=%~dp0Output_DXT5_BC3\ SET @TEXCONVEXE=%~dp0texconv.exe SET @TEXCONVEXE02=%~dp0texconv.exe :: Check for texconv.exe IF EXIST "%@TEXCONVEXE%" SET @TEXCONVEXE=1 IF "%@TEXCONVEXE%"=="1" GOTO EXESTATE_1  :EXESTATE_0 TITLE - ERROR! texconv.exe not found!!! COLOR 04 ECHO: && ECHO: && ECHO: ECHO                 === ERROR! texconv.exe not found!=== ECHO: ECHO     Install Path: "%~dp0texconv.exe" ECHO: ECHO    The script needs texconv.exe in order to work properly. ECHO: ECHO    Please make sure texconv.exe is in: "%~dp0"  ECHO: && ECHO:  GOTO CONT01   :EXESTATE_1 TITLE - Texconv.exe found!!! COLOR 0A  ECHO: && ECHO: && ECHO: ECHO                 [ texconv.exe Is Installed! ] ECHO: ECHO     "%~dp0texconv.exe" ECHO: GOTO CONT00 :CONT01 ECHO: && ECHO: ECHO        Please copy/move the missing texconv.exe executable to where the script needs it to be and refresh this window. ECHO: :CONT00 IF "%@TEXCONVEXE%"=="1" GOTO START ECHO: && ECHO: && ECHO     [Press any key to refresh the window] && PAUSE>NUL GOTO SetTexConvPath  :START  :: Customize CMD Window TITLE HumanStuff TexConv Batch Directory Script v1.0.2 PROMPT $G COLOR 04 CLS :: Make The Folders IF NOT EXIST "%@InputFolder%" MKDIR "%@InputFolder%" IF NOT EXIST "%@OutputFolder%" MKDIR "%@OutputFolder%" ::Run TexConv.exe ::-srgb was added because PNG images were getting high contrast colors ::Sorry about the messy code but this was harder to do than it sounds FOR /R "%@InputFolder%" %%i IN (*.*) DO ( set word=%@OutputFolder% set str=%%~dpi CALL :REPLACESTRING SET @IFOL=!@OSTRING! CALL :MKFOL SET @ISTRING=%%i CALL :TexConv01 ) PAUSE GOTO SCRIPTEND :MKFOL IF NOT EXIST "%@IFOL%" ( MKDIR "%@IFOL%" ) GOTO SCRIPTEND :TexConv01 IF NOT "%@LOGO%"=="" SET @LOGO=-nologo "%@TEXCONVEXE02%" %@LOGO% -srgb -nogpu -pow2 -vflip -if triangle -bc u -f %@FORMAT% "%@ISTRING%" -o "%@OSTRING%" -y ECHO: SET @LOGO= GOTO SCRIPTEND :REPLACESTRING call set str=%%str:%@InputFolder%=%word%%% set @OSTRING=!str:~0,-1! GOTO SCRIPTEND :SCRIPTEND $$$$  ## Writing a plugin to track user purchase and post back that using API? [closed] I am writing a plugin to track user purchase and post back that using API. First the user visit a third party listing site and logs in. Then he clicks the listing and visits a wordpress store with this plugin. I need to store that user info for 30 days. In that window period if he makes purchase i will pay commission to the third party listing site. Can you suggest any code examples or free and paid plugins to look at. ## I’m writing in an NPC that will become a wizard – how long will it take them to level up? [closed] There’s an option in my campaign that the characters can save a man cursed to be a stag, and if they can reverse the curse he will be really grateful, but doesn’t have anything to repay them with. I want to turn him into a wizard (lvl 5+ preferably) and then have him come back into contact and give them some magical calling item so he can come and fight alongside them once to help them out and settle his debt. How long does it make sense to wait (in game time) before the NPC could be Lvl 5+? I want to keep it realistic but I also don’t want to sit on it so long they forget who he is. ## Writing a list of names, with a limited amount of “active” letters at a time. Algorithm to sort the names to reduce the amount of swapping letters? While making name-tags for a dinner seating, I stumbled upon a problem which I can’t find any algorithm to solve, and I’m not sure where to begin. The goal is to write the name of each dinner guest on a card, completing one name at a time. The names are written with old-fashioned rubber stamps, so only 6 letters can be "active" at any given time. When a new letter is required, one of the active letters has to be swapped out for the new letter. The problem is to sort the names in such an order, that I need to do the least amount of letter-swapping. Example I want to write the names: • Jack • Julie • Chuck I can do this with 3 letter-swaps Initial letters: J A C K H U Write: Jack, Chuck {swap A, C, K with L, I, E} New active letters: J L I E H U Write: Julie Now I want to find an algorithm that, given a list of names and a limit of active characters, provide the order of names and which letters to swap at each name, to reduce the total amount of letter-swaps. Any ideas or pointers are welcome. ## how to get rid of curly brackets writing minimization output to file I have the following code SetDirectory["C:\test"]; fname = FileNameJoin[{%, "results.dat"}]; str = OpenWrite[fname, FormatType -> StandardForm] D1 = 0.4; D2start = 0.26; D2fin = 0.5; Ntot = 12; D2step = (D2fin - D2start)/Ntot; For[i = 0, i <= Ntot, i++, D2 = D2start + i*D2step ; With[{minsol = NMinimize[fnew[D1, D2, x], x]}, fmin = First@minsol; xn = Values@ Last@ minsol;]; Write[str, D2, " ", xn]; ] Close[str];  i.e I minimize the function fnew wrt x and write the value of x in the file results.dat. The problem is that the output is 0.26 {0.711259} 0.28 {0.744881} 0.3 {0.776204} 0.32 {0.805418} etc.  How do I get rid of these annoying curly brackets? ## Writing generalized hypergeometric function${_nF}_{n-1}(\cdot)$as a function of$n\$

How can we code the hypergeometric function $$f(n,k,z)={_nF}_{n-1}{\huge(}{1-k,\overbrace{2,\dots,2}^{n-1\ \text{times}} \atop \underbrace{1,\dots,1}_{n-1\ \text{times}}};z{\huge)}$$ as a function that accepts any $$n=1,2,3,\dots$$? This function reduces to a rational function in $$z$$ but that is not what I’m after. I apologize for lack of an attempt here…did not have any idea where to start.