Questions tagged [scripting]

For questions about Wolfram Language Scripts (formerly known as Mathematica Script), or running the kernel without direct user interaction.

Filter by
Sorted by
Tagged with
3 votes
4 answers
162 views

Sort Column as a Row

I have a = {1, 2, 3, 10}; b= {2, 3, 4, 8}; t= Do[If[a[[i]]+b[[i]]>3,Print[a[[i]]],"No"],{i,1,4}]; 2 3 10 I need to get the result; t={2,3,10}
4 votes
1 answer
108 views

Is the WolframScript error message "The product exited because of a license error" accurate?

I find that sometimes when I use wolframscript to run a .wls file (as part of a workflow involving hundreds of such files), its ...
3 votes
5 answers
90 views

Code should not evaluate at non-integers, fail at too few integers

I want this piece of code to sort a given list by odds first and evens last. This piece of code did the trick with the list I entered in: ...
1 vote
1 answer
124 views

Running the Mathematica script in SQL Server

Hi i am trying to learn mathematica. I am following instruction in one of the questions asked before and did the following: In SQL Server a stored procedure is created as follows: ...
6 votes
7 answers
289 views

How to find the repeated elements in a vector

Is there a way to write a function where the input is a vector and the output is the elements in the vector that are repeated? I was trying to use something along the lines: ...
0 votes
0 answers
46 views

HeatMap visualization (ListDensityPlot)

I have two sets of values, e1 = {0.15,0.2,0.25,0.3,0.35,0.4,0.45,0.5,0.55,0.6,0.65,0.7,0.75,0.8} and ...
4 votes
1 answer
153 views

Formulate and solve a system of linear, first-order ODEs in Mathematica

I know this code is wrong, but I am not sure why. I have a system of coupled differential equations. The model is given by the following equations: $\frac{dS_0} {dt} = (1 - \mu_0) \rho_0 S_0 \frac{S_\...
0 votes
1 answer
183 views

Can I use WolframScript to solve this system of equations?

I have these three equations: ...
2 votes
1 answer
132 views

Consumer Maximization Problem Doesn't Work in Wolfram Mathematica

I'm trying to solve a problem that can be seen in the paper "The Role of the Structural Transformation in Aggregate Productivity". The problem is: Manually it is difficult to find the ...
9 votes
4 answers
236 views

Destructuring a list containing two items to use it as arguments to a binary function

I'm experimenting with the Through function. I suspect there is a way to use that function to obtain both the mean and difference of two values. But this doesn't ...
1 vote
1 answer
81 views

Insert a nonlinear PDE in Mathematica

I am new to Mathematica and trying to learn its language. I want to solve a non-linear PDE but don't know how to insert it. Would you please help me or give me some tutorial about it?
2 votes
1 answer
65 views

Is it possible to speed up loading time of Mathematica script?

Even a simple #!/usr/bin/env wolframscript (* ::Package:: *) Print[1] takes 3 seconds to finish on my computer. Can Mathematica script load only what it needs for ...
1 vote
0 answers
63 views

Export data vertically

I have data that I want to export to a text file. ...
2 votes
0 answers
48 views

File formats of the Wolfram language [duplicate]

I am new user of Wolfram language and Wolfram Mathematica. And want to understand differences and purpose between file formats of ".m", ".wl" and ".wls". I have read ...
0 votes
0 answers
33 views

How Do I Graph an SVEIAR function with the reproduction Number

Just need help figuring out how to plot a graph of an SVEIAR model with its' reproduction number. I'm a bit confused on how to properly make a graph based off the model and reproduction number. ...
0 votes
0 answers
52 views

I need help with plotting and SVEIAR Code with the Reproduction Number on Mathematica

I need help because everytime I plot it doesn't work. ...
1 vote
3 answers
149 views

Converting Wolfram Language Scripts (.wls) into PDFs

I have just discovered the free (as in free beer) Wolfram Engine, coming with a generous licence. After playing with Mathematica for a while, and missing the notebook feature, I would like to generate ...
2 votes
1 answer
439 views

Wolframscript kernel in Visual Studio Code

I installed the free Wolfram Script and Wolfram Engine on my Mac (I do not have Mathematica), and I generated free activation keys. After entering these keys into the terminal, I am able to run ...
3 votes
2 answers
198 views

Importing a text file of values and converting it to table

I just started using Mathematica. I got some output in a txt file from some computations in Pari/GP which looks like this: $$ [1,2,3,4; 5,6,7,8]$$ Here I want to import the data into Mathematica and ...
0 votes
0 answers
27 views

How to solve unexpected behaviour with function calls in wolframscript?

I have the following piece of code saved as script.wls that is called using wolframscript -file script.wls <inputs> ...
14 votes
1 answer
2k views

Difference between math and wolframscript

It seems that both math and wolframscript can be used to run Mathematica scripts on the ...
0 votes
0 answers
77 views

How to pass variables from Python to Mathematica?

I have a Mathematica code that I want to run via Python using subprocess. The Mathematica code contains two variables that I want to pass through Python. However, when I tried to do that, I always got ...
0 votes
0 answers
52 views

How to insert/type the square brackets in Wolfram Engine/script window? [duplicate]

(Win10 with spanish QWERTY keyboard, using Fn key to obtain []. Wolfram Engine/script 13.3 or previous) I can type the square brackets (curly braces / parentheses, curly brackets) in the "System ...
0 votes
0 answers
62 views

Plot the resolvent operator function of a second order differential operator

I would like to plot the resolvent operator function of the following second order differential operator in $ L^1(0,+\infty)$, given by: $$(A) f(t)= \varepsilon f''(t) + b(t)f'(t)+c(t)f(t), \quad t\in ...
5 votes
0 answers
69 views

What is the most convenient way to organize dependencies from paclets?

Do you have any ideas on how to most conveniently and easily organize package dependencies for Wolfram Language projects. I would like to have something like a list of packages in projects for .Net ...
-1 votes
1 answer
77 views

Finding the dimensions of the cylinder that can cover $n$ given smaller cylinders (based on empty space, not least materials)

Let $r_k$ and $h_k$ be, respectively, the radius and the height of the $k^\text{th}$ cylinder. We have $n$ cylinders. Let $R$ and $H$ be, respectively, the radius and the height of the big that can ...
0 votes
1 answer
114 views

Is there a way to make WolframScript give outputs as a single line?

When the output of a calculation includes exponents or fractions, WolframScript is writing them out on separate lines (exponents one line above, then a line with the rest of the numerator, then a line ...
0 votes
1 answer
66 views

Way to stop reading script file based on conditions, without an "if" block wrapping the entire file

I have a bunch of definitions written in a file that I load with Get["..."], . I would like add a line into the the file so that the evaluation of these ...
1 vote
0 answers
76 views

Plotting equipotentials line of a Julia set in Mathematica

I need to plot the equipotential lines of the Julia sets of the polynomial $f(x)=x^2-1$ by using Mathematica, but I don't have a good background in programming. Given $f$, with equipotential lines I ...
6 votes
2 answers
189 views

Passing negative parameters to a wolframscript

How do you pass negative values as input for a wolframscript? This documentation page explains that the syntax for passing parameters is: ...
0 votes
0 answers
37 views

Data Export not working when running module using Wolframscript compared to executing in notebook

I have a Mathematica module im_solver.m that I wish to iterate through Python or a bash script. The module runs a bunch o' other modules. At the end im_solver.m executes a diagnostic.m that collects ...
3 votes
1 answer
214 views

Shading an area enclosed by a loop

I am plotting the folium of Descartes as a parametric plot, and trying to find the arclength and the area enclosed by the loop. I got both of them covered result-wise, but my professor wants us to ...
1 vote
1 answer
225 views

Wolfram script does not work due to memory shortage and/or "license error" (FacialFeatures function)

I am trying to run a wolfram script on my windows cmd prompt. The script (available here) uses the function Facial Features of Mathematica. It is important to highlight that I need to process this ...
3 votes
2 answers
152 views

Entering matrices interactively

I am looking for a way to enter an m*n matrix interactively using a dialog or a Graphical User Interface(GUI). Further, I would like to use this matrix later for ...
2 votes
1 answer
129 views

WSL/Ubuntu breaks evaluation of WolframScript batch file via symbolic link

I have a very useful bash script for pre-processing a Mathematica notebook before committing it to my local git repo. It works fine under Windows/Cygwin and under Linux. I like to keep one master copy ...
0 votes
0 answers
230 views

Correct way to plot with wolframscript

I am trying to run a .m file with wolfram script. I use the command wolframscript -file name.m It works until the program arrives to a ...
2 votes
3 answers
111 views

How to make an element in a list nested within a list have a default value?

I would like to be able to skip the necessity of entering the last element in the nested lists, and get some default value instead if they are not entered. Below are two lines of code. The first line ...
5 votes
5 answers
2k views

How can I ignore an argument?

I made some code (attached below). It is meant to make a list of random numbers that is not divisible by some value k. I wish to be able to not enter a value k, and have the code run regardless. It ...
3 votes
3 answers
453 views

How to make a function take another function as an input?

I am quite new to mathematica, and I simply want to know how to make a custom function, take another arbitrary function as an input. I have attached code that shows what I am trying to accomplish (...
1 vote
2 answers
245 views

Function within For Loop wont give me any output [closed]

...
1 vote
0 answers
117 views

How to run Mathematica from a bash script file? [closed]

I would like to run a Mathematica package math-simple.m file inside of a bash script file. Howeever, when I write inside of the bash script as: math -noprompt -script math-simple.m I get a warning as /...
0 votes
0 answers
95 views

How can I retain an old version of wolframscript during an upgrade?

During the process of upgrading Mathematica to a newer version, we are presented with the choice of retaining or uninstalling an older version. But it seems that this choice does not extend to ...
3 votes
1 answer
55 views

How to force standard output as FortranForm while calling a script from terminal

Here's a simple script saved in the file fortranOutput.wls x = ToExpression[$ScriptCommandLine[[2]]] d=FortranForm[x] Print[d] When I call this function from the ...
0 votes
0 answers
58 views

Can Mathematica automatically submit a code for evaluation every 10 seconds?

I would like to automatize Mathematica to run the code: [Geolocation] every ten seconds. Is that possible? I have searched online, but could not find any ...
1 vote
2 answers
234 views

Can we solve the following integral by MATHEMATICA?

I am trying to solve the integral using the following Mathematica code. f1 = (t[m + 1] - t)^(\[Alpha] - 1)*(t - t[m - 1])*(t - t[m - 2]); ...
2 votes
3 answers
119 views

Removing lists containing some rules

Consider a big list of lists of rules, namely ...
0 votes
1 answer
57 views

Getting 3 points although the code describes 1 point in the plane

I'm trying to plot the closest point in the plane to the point P (the one that can be dragged) but in the graph appears 3 points. in the graph I'm plotting a plane and a point P, I want to add another ...
4 votes
1 answer
387 views

Run .m file in terminal [closed]

I have the following .m file (* ::Package:: *) (* ::Input:: *) (*out=1+1;*) (*Print["Test"];*) (*Export["/path/test.txt",out];*) and I am trying to run it in the ...
4 votes
1 answer
87 views

Graphing the equation only after the right answer is picked

I need the equation in the question to be graphed only after the right answer is picked I'm using this form to write questions : ...
1 vote
0 answers
56 views

how to add questions with grades

I want to add questions with grades, I'm using this form to write questions : ...

1
2 3 4 5
8