Turn string with () as function brackets into expression
I have a text file with an equation where all the brackets are formatted as (). For example I read in the equation 2*(Re(a)+Im(b)) as a string. Now I am wondering if I can make this into an expression...
View ArticleHow to get the desired LLM response in string robustly with and without using...
I am trying to query a large language model from VS code using WolframEngine.However, ImportSting with JSON options does not work in extract the desired output string of the LLM response. So I use the...
View ArticleHow to properly write fraction in style
I would like to write the following for the legend of a curve :$$ Theta = \frac{\pi}{2}$$Where the value $\frac{\pi}{2}$ is actually in a variable named $Theta$ (same name as the text on the lhs of the...
View ArticleMatch two lists based on same elements
I have two large lists:list1 = {{a,v},{a,h},{b,v},{b,k},{c,t},{c,r},{d,r}};list2 = {{v,dc},{v,rt},{h,kl},{h,oi},{h,po},{k,ö},{k,dc},{t,re},{r,qw},{r,ay},{r,ül}};Now I want a list that matches both...
View ArticleHow to speed up ToString[#,TeXForm]&?
Try the following code to convert the expression to LaTeX codef = Expand[(x/2 + y/3 + z/5 + 1/7)^20];str = ToString[f,TeXForm]; // AbsoluteTimingIt took about 1 minute, while sympy.latex only took 0.6...
View ArticleHow to parse out a word's position in a data set
I'm trying to find better ways to import data. My data set is a CSV that contains a parameters at the end of the file. For example in this two part list I want to find the position at which the word...
View ArticleConverting variable value to a string [duplicate]
I can run this with no problem:Import[NotebookDirectory[] <> "a10.mx"];Instead of that, I want to describe 10 with a variable as k,k = 10;Import[NotebookDirectory[] <> StringForm["a``.mx",...
View ArticleHow to set to 0 all terms in a matrix which contain a minus, revisited
The previous question How to set to 0 all terms in a matrix which contain a minus seems to have a wrong answer. For the matrixM = {{-ai - ar + ba s - \[Mu], bi s}, {ai, -\[Gamma]i - \[Delta] -...
View ArticleEscaping multiline strings in Mathematica
I want to assign long multi-line strings in Mathematica. Is there a way of delineating a block without having to escape each instance of '"' with '\"' and each line ending with '\'?i.e. In other...
View Article