Message Boards Message Boards

GROUPS:

Why does the command "where" work not always?

Posted 3 years ago
12321 Views
|
7 Replies
|
0 Total Likes
|

Hello,

I am very new to Wolframalpha and find it quite fascinating. But as I wanted to combine 4 derivatives of a single long function f, the input line was too short. So I tried some kind of substitution and found that such commands work:

f*2+f^2 where f=sin(x)

Here sin(x) is substituted for the letter f twice. BUT with derivatives the "where" command seems to fail sometimes, e.g.

(df/dx)+1 where f=sin(x)

Here the sin derivative is not performed. But with

df/dx where f=sin(x)

it works. Result: cos(x).

Therefore my question: Why does the substitution of f with the command "where" sometimes work and with a small variation it does not work anymore. Ist there maybe a better way to define a function f in advance or to substitute it?

7 Replies
In[8]:= ?Where

During evaluation of In[8]:= Information::notfound: Symbol Where not found. >>

In[9]:= f[x_] := Sin[x]

In[10]:= 2 f[x] + Sin[x]^2

Out[10]= 2 Sin[x] + Sin[x]^2

In[11]:= f'[x] + 1

Out[11]= 1 + Cos[x]
Posted 3 years ago

Thank you for the reply. It shows that the substitution works in Wolfram, but I have not yet bought the programme, instead I am trying to do this calculation on the single-line input of the Wolframalpha website:

http://www.wolframalpha.com/ (here with our input: http://www.wolframalpha.com/input/?i=2*f[x]+where+f[x]%3A%3DSin[x])

Here only one line of command is possible and thus the function assignment is not as easy as with the multi-line input in the full version. However, there is also the possibility of assignment with the "where" keyword (maybe a different command is better) as you see in my example N°1 and N°3 above. But it works only for some inputs and I am wondering why it does not work for all imputs like in my second example. I think the interpretation of the input is straightforward, but somehow it is not understood by Wolframalpha.

This is very surprising to me for such an easy input, because usually Wolframalpha understands more complicated input e.g. in unit transformations.

Can anyone help me with some correct input syntax to make things like "(df/dx)+1 where f=sin(x)" work in Wolframalpha?

Therefore my question: Why does the substitution of f with the command "where" sometimes work and with a small variation it does not work anymore.

it's all about input interpretation, of course: The program (Mathematica) has a free language input (the orange equal sign), working with it one gets

misinterpretation

as you see, the input interpretation is correct in $\LaTeX$, but not in Mathematica, it must be

In[18]:= 1 + Derivative[1][f][x] /. {f -> Sin}
Out[18]= 1 + Cos[x]

Two other interpretations missing the point are

missingThePoint

to be honest I was inapt to get the result out of the free language input with Mathematica 10.1 within half an hour.

to be honest I was inapt to get the result out of the free language input with Mathematica 10.1 within half an hour.

but here is my favourite of free language input so far:

enter image description here

it's really supportive, in a way. That could be good if the user is in an exercise of wandering mind.

Posted 3 years ago

Hello Dent de Lion,

very funny and curious answers that you got from Wolframalpha. ;-)

In fact I tried all your suggested notations like "/. {f -> sin(x)}", "D[f, x]" and they always work with the easy formula, like the derivative of sin(x) alone. But when you add "+1" to the expression which shall be derived, then the interpretation goes wrong or the programme writes down sin'(x) or sin(x)' but does not evaluate it to cos(x). Why not? It seems to understand that it should now compute the derivative of sin(x) but it does NOT do it. Very strange, because if you do the derivative directly e.g. "d (sin(x)+1)/dx" it does it, even for very complicated input. This should do with substituting the complex input as f, too.

It seems to understand that it should now compute the derivative of sin(x) but it does NOT do it.

It can't do it because it applies the wrong rule, it does

In[1]:= 1 + Derivative[1][f][x] /. {f -> Sin[x]}
Out[1]= 1 + Derivative[1][Sin[x]][x]

which is wrong (it is $1+Sin[x]'[x]$) instead of

In[2]:= 1 + Derivative[1][f][x] /. {f -> Sin}
Out[2]= 1 + Cos[x]

In mathematics too, you don't write $1+\sin(x)'(x)$ for the derivative of $\sin$, of course you write $1+\sin'(x)$. The problem here is the Substitution of Sin[x] into the head of Derivative.

Posted 3 years ago

Well, I did not find out how to do the assignment of a function to a letter (e.g. f(x) = sin(x)) work with the single command line in Wolframalpha - except for the very simple case shown above. So I found an old Maxima release that I had on an old CD from university times. There the calculation worked out fine.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract