6
$\begingroup$

In Maple, you right click and can evaluate an expression (whatever it is) at a specific point say:

Expr.= abcddafjosjfoj, then right click and simply evaluate at c=-34 say. But how does one do the correspoinding operation in Mathematica? Must one define a function first for this simple task?

image

$\endgroup$
  • $\begingroup$ Right click and then evaluate c=-34? Huh, because c is present in abcddafjosjfoj? What do you mean? If there were spaces between the characters here, you could use the menu item evaluate in place. $\endgroup$ – Jacob Akkerboom Jun 5 '13 at 15:40
  • $\begingroup$ Yes exactly you right click whatever expression you like and evaluate at whatever you like. So my question is how to do that in Mathematica? $\endgroup$ – mapel Jun 5 '13 at 15:41
  • $\begingroup$ For instance if I have an expression called E so that E=abcde...*f, then I right click on it and evaluate at point c=-34 so that E becomes E=-34*abd*...*f. Nice and simple, but what is the corr. operation in Mathematica? $\endgroup$ – mapel Jun 5 '13 at 15:45
  • 2
    $\begingroup$ I added an image - is this what you're describing? $\endgroup$ – cormullion Jun 5 '13 at 15:52
  • $\begingroup$ Yes exactly cormullion. Great job! $\endgroup$ – mapel Jun 5 '13 at 15:54
9
$\begingroup$

In Mathematica this can be done any number of different ways, but the spirit of your question suggests replacement rules as the solution you're looking for.

Consider x (a delayed expession; will re-evaluate RHS each time 'x' is evaluated)

x := 4*c^2

Now use ReplaceAll (shorthand notation is /.) and a Rule (shorthand notation is ->)

x /. c -> 2.5

(*25.*)

Note you can also try a number of these at once:

x /. c -> {2.5, 3, 8}

(*{25., 36, 256}*)

See the docs on ReplaceAll and Rule for more examples. An alternative approach would be to define a function and pass values explicitly.

$\endgroup$
  • $\begingroup$ I think you nailed it bro. I'll try it out and comment soon. $\endgroup$ – mapel Jun 5 '13 at 15:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.