Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [functions]

Questions about the use of built-in Mathematica functions, including pure functions.

0
votes
0answers
13 views

Make traditional output for integrates [duplicate]

I want to perform a traditional output for integrates using a new function that I called HInt: ...
0
votes
0answers
25 views

Using `Format` to create a notation for derivatives

I want to create a new function that I called HD to give a visual way to see the derivatives. For example: The objective is apply the function ...
2
votes
1answer
30 views

Draw a graph and write its function based on the values and derivatives at different points?

This is a very general question since googling didn't bring anything useful up for me. Suppose that I have the value of a function at some points plus the derivatives at those points. Now I am looking ...
3
votes
2answers
51 views

Iconize behaves in a confusing manner

When I evaluate Iconize[Range[10], "range10"], it returns an icon labled "range10", which if evaluated returns ...
0
votes
0answers
36 views

Optional argument in Set Function

Optional arguments can be defined in SetDelayed (:=) Functions (see f1 below and here and here). However, how can one accomplish this in Set (=) Functions (see f2 and f3 below)? ...
1
vote
2answers
62 views

UnsameQ exhibits different behavior than !SameQ

I do not understand the UnsameQ[] behavior below. (I need UnsameQ[] as I may have variables in the array.) ...
0
votes
0answers
26 views

Change the attributes of the function `Format`

I think that the function Format has intrinsic an orderless attribute. So I've tried to create the following function: ...
0
votes
0answers
29 views

Defining a derivative as a function does not work

I have a fairly complicated function VIcase1L[b_,\[Epsilon]_, d_] := ....... All I wanted to to was to derive it this function with respect to b and define it. ...
0
votes
0answers
27 views

How to verify if all elements of a list are equal [duplicate]

I have a result in a list form: {1,2,3,4,5,6} How to verify if the elements are equal? If I use Equal doesn't works with a list....
1
vote
0answers
50 views

Calling a notebook from a different notebook

Basically I have a notebook (let's call it nb1) that when evaluated yields one number when I specify some parameter $\alpha$ (in nb1). I want to call nb1 in a different notebook (nb2) using for ...
2
votes
3answers
185 views

How to apply `Length` in all elements

I want to apply Length in each element from a list. For example: My list is: {1,{2,3},{4,5,6}} How to apply ...
3
votes
1answer
23 views

Why doesn't this Kronecker Product work with columns, but with rows?

Using the formula given in this math.stackexchange answer by the user greg $$\eqalign{ vec(M\otimes dK) &= \left(\pmatrix{I_T\otimes (M \cdot e_1)\cr I_T\otimes (M \cdot e_2)\cr \vdots \cr I_T \...
1
vote
2answers
52 views

Why does Sum[Length[Divisors[a]], {a, 1 ,x}] return x?

I am summing the number of divisors and I am getting the strange answer below even where there is no input to this function. ...
18
votes
5answers
1k views

Sisyphus Random Walk

A Sisyphus Random Walk evolves as follows: With probability (r) you advance the position of the walker by +1. With probability (1-r) the walker resets at x0 = 0. To simulate the probability of reset ...
0
votes
0answers
11 views

How do i differentiate a cosx function when x is in degrees? [migrated]

i have been having a hard trouble working on excercise 4a since i cannot understand how to differentiate a trig function that has x in degrees. How is it done? .
0
votes
0answers
30 views

Create library of custom functions [duplicate]

I have been trying to create a library of custom functions that I could just call at the start of every notebook. For instance, say I want the following functions to be part of the Library, or even ...
3
votes
1answer
83 views

HoldFirst being overridden by Activate

So here's the problem a=1;a=2 works because of the HoldFirst attribute of Set, so that it ...
4
votes
2answers
649 views

Mathematica gives an unexpected answer for Integrate [closed]

I need to integrate the following: \begin{equation}\tag{1} \frac{\sqrt{C + (1 - C) x^3}}{x}, \end{equation} where $0 < C < 1$ and $x$ is a positive variable (then $x^3 \ge 0$). When I integrate:...
0
votes
1answer
34 views

Use of module and nested variables [closed]

Consider the following: rule = x -> 2 para + 1 funct[para_] := Module[{x}, x /. rule] this unfortunately does not work. If I put the content of "rule" ...
1
vote
1answer
39 views

Function definition with sub (super) cripted variables [duplicate]

I like using subscripts a lot. However, it is regrettably not possible to do, for example: myfunction[Subscript[x,1]_] := Subscript[x,1] +1 where instead of the ...
0
votes
1answer
46 views

Plotting a function of 3 variables while keeping 2 of them fixed

For illustration I made a simplified version of my function: ...
1
vote
1answer
57 views

How can one change variables in a function?

To be completely honest I am a litte lost. Let us say a variable x is defined as y = 1/x. I have one function f[x_]:= x^2 which I would like to multiply into ...
7
votes
5answers
982 views

Survival Probability for Random Walks

The Survival Probability for a walker starting at the origin is defined as the probability that the walker stays positive through n steps. Thanks to the Sparre-Andersen Theorem I know this PDF is ...
1
vote
2answers
46 views

What does 'Module' do when defining a function? [closed]

I have an exercise class where I need to understand a specific function. without posting the whole big code into here I'd like to understand the basic ...
0
votes
0answers
25 views

Minimum of explicit functions in vector form

For fun, related to this question about minimizing implicit functions, how can I find the minimum of an explicit one expressed as a vector? For instance, an ellipse: ...
5
votes
1answer
121 views

Install Function from “Wolfram Research Server” Offline

I recently used Mathematica's "IntegerName" function, but upon calling it for the first time, I was surprised to be greeted by a message reading: "Installing data from wolfram research server.." ...
1
vote
3answers
68 views

Creating a function that checks whether input is an integer (in the mathematical sense)

I am creating an alternative function of IntegerQ[] function. Now I don't want any output. I just want my function to check whether this is integer or not. I'm ...
2
votes
1answer
81 views

How to use external Mathematica Code? [duplicate]

I have a Mathematica Notebook with a function that i would like to be able to access from another Notebook without having to have the first Notebook open. The functions calls other functions in the ...
3
votes
2answers
784 views

Determining if a number is divisible by 1000 [closed]

I have a number such as: a = 875952; And I want to find if it is divisible by 1000. Is there a concise way of doing that?
1
vote
0answers
44 views

How to preserve braces in result

I have a result from equation, for example p={{0<=x<=1/5||x==9/10},{0<=x<=1/5||x==9/10}} and using Cases[p, z_?NumericQ -> z, Infinity] I get {0,1/5,9/10,0,1/5,9/10} But I ...
0
votes
1answer
77 views

Solving a difficult differential equation

I've the following DE, describing a physical phenomenon. And the prupose is to solve that DE using Mathematica $$x(t)\cdot r+x'(t)\cdot l+a\cdot\ln\left(1+\frac{x(t)}{b}\right)=0\space\...
0
votes
0answers
34 views

Function that once called “erase” every other definition of my notebook

I encounter a really weird effect in Mathematica and I don't know what the wrong thing is nor how to correct it. I work with vectors of four components and I have a minimal set of definitions that I ...
1
vote
0answers
60 views

What is exactly an element a[i] in mathematica? [duplicate]

I'm confused about the logic behind mathematica programming. We can have function that will be called doing $f[x]$, thus the element $f[x]$ can be seen as the return value of a function taking an ...
0
votes
1answer
77 views

Why doesn't this function take a list as an argument?

I created this code to calculate an approximation to an integral, using the Trapezoid Rule and the Midpoint Rule. Here the output is a table for N=16. Question: what would be a simple way to create ...
0
votes
1answer
66 views

Plotting the condorcet jury theorem [closed]

I am trying to create a simple plot of the condorcet jury theorem: The function is: F[n_,i_,p_]:=((n!)/((n-i)!*i!))*((p^i) *(1-p)^(n-i)) embedded in a sum ...
1
vote
3answers
81 views

Evaluating complicated limits correctly

Let's say I have defined some function: a[x_] = x^2 Log[x^2]. If I try to evaluate a[0] Mathematica will complain that it is ...
3
votes
4answers
179 views

Continuous non-piecewise equivalent of smoothstep function?

I have a smooth step function given by the piecewise function ...
0
votes
1answer
85 views

How to use a test function correctly to terminate a While loop?

I define a test function in order to stop my While loop: ...
9
votes
1answer
175 views

Force evaluation of user-defined function

Consider a function that sorts its arguments based on a function called order ...
1
vote
2answers
52 views

Defining a function that treats input as two unordered lists

I have a function f2 I'd like to code into Mathematica with the property that it takes in two lists, treats those lists as unordered, and maps to a symbolic value. If I were instead using a function ...
0
votes
1answer
65 views

Convert a piecewise definition of a single impulse into an impulse train

NOTE: See update at end of question I have a function smoothstep (based on the derivative of a smoothstep function) that gives a single impulse as follows: ...
0
votes
2answers
51 views

Problem with FindShortestTour function

I'm new to Mathematica but I've read some documentation and guides and, unfortunately, haven't found a solution. There's the following matrix in the task: And I have to solve this TSP problem ...
0
votes
0answers
25 views

How can I access the name of a variable inside a function? [duplicate]

How can I access the name of a variable inside a function? For example I have variables mike={some stuff} jenny={other stuff} and want to write a function f giving the following: input> f[mike] ...
1
vote
3answers
65 views

How to write a discrete function which depends on pairity

Consider the following function for example $$ k = \sum_{n=0}^{\infty} \Gamma(\frac{n+1}{2}) y(n)$$ $$y(n)=\cases{2^{\frac{n}{2}} \text{ even}\\ 2^{\frac{n+1}{2}} \text{ odd}}$$ How can such function ...
5
votes
1answer
101 views

Defining multiple functions

I have a matrix with 4 elements that I want to turn into functions without explicitely defininig all the functions "by hand": ...
1
vote
1answer
41 views

How to represent characteristic function of a single-point set?

I am trying to find the way how to represent characteristic function of a single-point set. My idea was to write the points by set: Ainput = {{2/5, 1/4}}; ListPlot[Ainput, PlotRange -> {{0, 1},...
4
votes
1answer
111 views

Integers with a given digit sum

My aim is to generate a list of integers less than a given value $r$ with their digit sum equal to $s$. My code given below works fine but it is slow. I would like to see efficient versions. ...
0
votes
1answer
55 views

How can I get all the order of a list? [closed]

I have a list such as : {1,3,6}, then, I want to get all the orders of it, I do not know which function is easier. I have to try this code, but it is complex. ...
0
votes
1answer
35 views

How can I construct binomial terms using the Binomial function? [closed]

I want to construct a table of the terms Binomial[n, i] t^i (1-t)^(n-i) where i goes from 0 to ...
0
votes
0answers
69 views

Find the maximum of a function involved with Floor function

My function is $$ f(H,p) = \left\lfloor \dfrac{\lfloor H/p\rfloor + 3 - \sqrt{(\lfloor H/p\rfloor + 1)^2 - 4H}}{2} \right\rfloor $$ The constraints are $ H \geq p(4p-1) $, $ p $ is prime although ...