Questions tagged [functions]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
44 views

Using the (long) out of a function to define another function [duplicate]

It might be a trivial question but I haven't been able to find solution myself. Suppose that I have a calculation whose rather long output that is dependent in some variable e.g. ...
1
vote
0answers
63 views

Basic mathematica coding package examples [duplicate]

Since Google and Mathematica documentation has proven utterly useless at answering my question... Does ANYONE have some BASIC examples of how to code up a package? For my course work, I have to ...
0
votes
0answers
45 views

Using module to define a function that calls another function: Should i use set-delayed (:=) or set (=)

Suppose that I have a function f[x_,y_,z_]=x*y*z and now suppose I want to consider a specific application where z is a ...
3
votes
2answers
485 views

How to obtain numerical solutions of a two-variable equation?

I have a two-variable function: f[x_, y_] := (4 y^2 - 6) (Cos[y π] Cos[x] - Cos[2 y π] Sin[x]) How can I find all the numerical solutions for $x$ and $y$ such ...
2
votes
1answer
70 views

Newton's method of tangents

I am trying to solve this problem.I need to find a zero of a given function with Newton's method of tangents.The condition is f(x0)*f'(x0)>0 and then calculate ...
2
votes
0answers
20 views

`MatrixFunction` is returning a cryptic error message about “the function `1`”

The "Possible Issues" section of the documentation for MatrixFunction lists several possible ways in which a call to ...
1
vote
0answers
35 views

Need help plotting on Mathematica simple piecewise wave function from quantum physics (Quantum Physics, Griffiths, 2.7) [closed]

On Mathematica need to plot an initial wave function defined as... Psi(x,0) = Ax when 0 <= x <= a/2 Psi(x,0) = A(a - x) when a/2 <= x <= a Here is my attempted code... ...
1
vote
1answer
41 views

How to ask the user via Input a Function? - Wolfram Mathematica

I need to ask the user the function to make some procedures. For example, instead of having at the code f[x_] := Sqrt[1 + x]; and then ...
0
votes
1answer
54 views

Find an instance of a Kaprekar number

Here are two instances of an Kaprekar number $\text{9${}^{\wedge} $2 = 81 $\&$ 8+1=9}$ $\text{8${}^{\wedge} $3 = 512 $\&$ 5+1+2=8}$ There are certainly more with a higher exponent , ...
4
votes
3answers
121 views

Among the first 10,000 multiples of 17

Hello I'm new with Mathematica and I can't find a way where I can do this condition. Among the first 10,000 multiples of 17 how many have the sum of their digit multiple of 17? The part for the ...
1
vote
1answer
63 views

Quick & neat Mma actions [closed]

I know that the expressions Series[Exp[x],{x,0,2}] and Exp[x]+O[x]^3are equivalent in Mathematica. I was wondering if a similar ...
5
votes
2answers
85 views

Making functions with the output of a ReplaceAll

I'm trying to make a function from the variable "replace" of next code: ...
1
vote
1answer
29 views

Applying functions to members of members… of lists of lists…, etc

Suppose that I have a list of depth $k$, and I want to apply a function $f$ to all elements at level $n$ - e.g. $f,\{\{\{a,b\},\{b,c\}\},\{\{c,d\}\}\},3\mapsto\{\{\{f(a),f(b)\},\{f(b),f(c)\}\},\{\{f(c)...
1
vote
1answer
55 views

Cache a function in mathematica

I have a function of one variable $f(x): \mathbb{R}\to \mathbb{C}$ which is very difficult to evaluate. Single evaluations may take hours, and I need to use the function at a large variety of points. ...
0
votes
0answers
41 views

Wigner 3j-symbol in mathematica

I am looking for a nice and workable formulation of the 3j-symbol in terms of hypergeometric functions. On the wolfram webpage I found: http://functions.wolfram.com/HypergeometricFunctions/...
3
votes
1answer
82 views

What does :Automatic in a function definition mean [closed]

I've been trying to figure it out, to no avail. In reading someone else's code, I come across a function definition, where it says something like this ...
1
vote
1answer
76 views

Is it feasible to curve fit to a staircase function? [closed]

Taking as a starting point the advice given in this post I am trying to fit data to a staircase function as follows: ...
2
votes
1answer
111 views

Plot nested integration of an InterpolatingFunction efficiently

Suppose we have an InterpolatingFunction from NDSolve ...
2
votes
1answer
106 views

For a multivariable polynomial of degree t, how can you find the coefficients of monomials of degree t?

Hello Mathematica StackExchange community, I'm hoping that someone can be of help! Let p be a fixed prime. I have a multivariable polynomial g (of degree t). I need a list of all the monomial terms ...
3
votes
1answer
93 views

Mathematica unable to evaluate function which it can write explicitly in simple form

I have a function $\psi(x,n)$ in mathematica which is quite complicated. However, plugging in $n=0$ gives a simple form. Mathematica knows this (see below), however it is still unable to even evaluate ...
2
votes
1answer
34 views

How do I make exponential graph show only one trend-line with two lists of data?

Below is my code containing two lists of data, I need the graph to show one exponential trendline from an exponential equation, but it currently shows one trendline per item in the list. I am sure ...
0
votes
1answer
23 views

Defining a conditional statement for a function

I am trying to define a function that is zero when it is evaluated on real numbers and on a preset list of symbols. I am doing this by using ...
4
votes
1answer
494 views

How this foo, ## & @@ work?

Can anyone explain the code below? The problem is in this part of the code. What is foo, ## & @@? I have been looking at ...
1
vote
1answer
40 views

Little confused about taking transformation

I have a function f, the value of the function at x=0 is zero and at x=2 it is one. I am trying to interchange this, meaning at x=0, f should take the value of one and at x=2 f should be zero. ...
0
votes
0answers
27 views

replacing a founded value in a function

Here is the sample F[r_] := r^2 + r^3 DerivI[r_] := D[F[r], r] A = FindRoot[DerivI[r], {r, 9}] B = F[r] /. r -> A I want to replace ...
4
votes
2answers
115 views

Making tables and update calculated values

I'm trying to make tables like in the image to calculate max and min of the expressions. Whenever I change the max and min of a and ...
0
votes
1answer
43 views

Two “different” call of the same expression give two different results… why?

Consider the following code: ...
0
votes
0answers
46 views

Extracting a linear equation from a graph

...
1
vote
0answers
63 views

Slot numbers, pure functions [closed]

For the first line of code my function works fine on the list, but when trying to use Map I just keep getting an error (Function::slotn) basically saying there are not enough arguments for it to work, ...
5
votes
4answers
284 views

Recursive function, if and which statements

I am given this question: Let a function $ T_n(x) $ be defined by: $$ T_{n+1}(x) = \frac{1}{x} T_{n-1}(x) - \frac{2}{7} T_n(x), $$ where $ T_0(x) = 1, T_1(x) = x $. I need to construct a recursive ...
1
vote
0answers
28 views

Do I have to write the independent variable always?

I'm not used to using Mathematica. Please help me. What I want to do is similar to the following: U and V are unknown function ...
2
votes
3answers
72 views

Function on nested lists

Please can someone help with this question, I'm a bit stuck. Write a function which will accept a list corresponding to a mark list, where each entry in the mark list has the form ...
4
votes
4answers
218 views

How to Force Evaluation of Derivative in a Pure Function Definition

Let's say I have a function f1 = #^2 &; I want to calculate its derivative, perform some manipulations and make the result a pure function. I try ...
0
votes
0answers
24 views

Variant on `PrimeZetaP`

Mathematica has PrimeZetaP for the prime zeta function $\sum_p \frac{1}{p^s}$ where the sum is taken over all primes. How do I use Mathematica to make an ...
5
votes
1answer
72 views

BreadthFirstScan and DepthFirstScan

Recently, I have been playing with the functions BreadthFirstScan and DepthFirstScan. I'm having a hard time understanding the ...
0
votes
2answers
61 views

Use `If` to create new list from old

I'm trying to use If and AppendTo to create a list by imposing conditions on an initial list. And I'm getting an error that "...
0
votes
0answers
32 views

Pulling answer from previous output

This will probably be a very simple answer. I am trying to find a way to pull the last output from a line and define it as a separate variable so it can be used in a later function. Specifically in ...
0
votes
0answers
46 views

Finding ellipse formulas from set of ellipse relations

Question: Given the ellipse relations below, what additional ellipse formulas/relations/equations can I derive? I asked a question similar to this in Finding formulas from other formulas and ...
0
votes
2answers
40 views

Truncating digits after calculation

I am working on numerical solutions to PDEs. I get some outputs which I then place back into the original equation to check my answers against expected values which are the original inputs. The ...
3
votes
2answers
83 views

How does mathematica decide what `x_` is in `MemberQ[list,x_/;(x==#)]&/@list`

Consider the following code: list={1,2} MemberQ[list, x_ /; (x == #)] & /@ list This gives {True,True} ...
0
votes
0answers
22 views

Using a Which statement with Graphics3D [duplicate]

*Problem solved in the comments I am trying to write a function that outputs a different graphic depending on the user's input, with four total options. I was making a test version and am running ...
2
votes
1answer
27 views

StringMatchQ with Alternatives

Why when trying to find whether one (out of several) patterns matches an expression - using StringMatchQ - all of them seem to be ignored and no matches are found? ...
3
votes
3answers
121 views

Is there a way to speed up the following calculation Table[If[TrueQ[],k,Nothing],{k,10^5,10^7}]

I've the following code: Table[If[TrueQ[2+3^k>2^k+(-1+2^k)*Floor[(3/2)^k]],k,Nothing],{k,10^5,10^7}] Is there a way to speed the calculation up in Mathematica ...
1
vote
0answers
45 views

Defining function with index [closed]

I have the following relation: (i=1,...,q). For defining li, I write: l[i_] := 2 R Sin[\[Phi][i]/2] where R is the radius of a circle, l[i] is the i-th length ...
3
votes
1answer
70 views

Plot function with parameters from Reduce

I would like to modify the question a bit. I want to plot the function m with different combination of (a1,b1,a2,b2) over a ...
5
votes
1answer
53 views

Creating a dynamic list of parameter defined functions

I'm trying to create a list of functions that is dynamic in size and defines function names like so: ...
0
votes
0answers
22 views

What is this function syntax doing? [duplicate]

I'm trying to work my way through another person's notebook. I came across this function definition: ...
4
votes
2answers
158 views

How to calculate volume under $ f(x, y) $?

I have the following function: σ = 0.3; μ = 5; cy =0; cx=0; f[x_,y_]=Exp[-(1/2)((Sqrt[(x-cx)^2+(y-cy)^2]-μ)/σ)^2]/(σ*Sqrt[2*π]) Plotting this with: ...
1
vote
0answers
52 views

Why is g[x] handled differently as f[x] from Mathematica? [closed]

When I execute this code: ...
0
votes
1answer
48 views

How to export a table of functions [closed]

Consider a table having rows {a, b, f[a,b,t]}, where a,b are parameters while f is a function of t (being the numeric solution of some differential equation). Is it ...

1 2 3 4 5 52