Message Boards Message Boards

0
|
14025 Views
|
7 Replies
|
5 Total Likes
View groups...
Share
Share this post:

Core language (Tutorial Collection) - pages 98 and 99

Posted 11 years ago
Dear:

Reading the Core Language cited above I typed the following instructions:
 odeplot[de_, y_, {x_, x0_, x1_}, opts : OptionsPattern[]] :=
 
  Module[{sol},
   sol = NDSolve[de, y, {x, x0, x1},
     FilterRules[{opts}, Options[NDSolve]]];
   if[Head[sol] === NDSolve,
    $Failed,
    Plot[Evaluate[y /. sol], {x, x0, x1},
    Evaluate[FilterRules[{opts}, Options[Plot]]]]
   ]
  ]
odeplot[{y''[x] + y[x] == 0, y[0] == 1, y'[0] == 0}, y[x], {x, 0, 10}]

Unfortunatelly it did not work but it worked when I delete the If, as you can see bellow (Plts Attachded):
odeplot[de_, y_, {x_, x0_, x1_}, opts : OptionsPattern[]] :=

Module[{sol},
  sol = NDSolve[de, y, {x, x0, x1},
    FilterRules[{opts}, Options[NDSolve]]];
  Plot[Evaluate[y /. sol], {x, x0, x1},
   Evaluate[FilterRules[{opts}, Options[Plot]]]]
  ]

Could you help me why does not work a simple program from Tutorial Collection ?

Thanks,
Ana
Attachments:
POSTED BY: Ana Squadri
7 Replies
Wolfram Language is, basically, the language of Mathematica.  (Present-tense verb, stay tuned.) 

Two pages I often point newbies to are,

  http://reference.wolfram.com/mathematica/tutorial/GettingUsedToMathematica.html

  http://reference.wolfram.com/mathematica/tutorial/GettingStartedOverview.html

I see that there is a WL equivalent for the latter:

  http://reference.wolfram.com/language/tutorial/GettingStartedOverview.html
POSTED BY: Bruce Miller
Posted 11 years ago
Thank you!!!
POSTED BY: Omer Ronen
Posted 11 years ago
it would be more accurate, i think, to say that Mathematica was the first knowledge domain in which the Wolfram Language was used. WL is a stand-alone programming language (i have programmed in it for 28 years and have only used a mathematical function one time). it is applicable to MANY fields besides mathematics and physics and engineering - in fact, to ANY field in which computation is employed.
POSTED BY: Richard Gaylord
Posted 11 years ago

Ally Clinton,

We are sorry your post was mangled.

Please try again. If the problem persists, please contact the moderators at
**wolfram-community@wolfram.com**
include the URL and name of the thread you are trying to add to.

Moderation Team

POSTED BY: Ally Clinton
Posted 11 years ago
Where did you guys learn the syntax for the wolfram language? Also are there any ways to use it without the raspberry pi?
POSTED BY: Omer Ronen
Posted 11 years ago
Effectively (If) command must have the i capitalized, the rest seems okay, here is the example of your code running
odeplot[de_, y_, {x_, x0_, x1_}, opts : OptionsPattern[]] :=
Module[{sol},
  sol = NDSolve[de, y, {x, x0, x1},
    FilterRules[{opts}, Options[NDSolve]]];
  If[Head[sol] === NDSolve, $Failed,
   Plot[Evaluate[y /. sol], {x, x0, x1},
    Evaluate[FilterRules[{opts}, Options[Plot]]]]]]
Example
odeplot[{y''[x] + y[x] == 0, y[0] == 1, y'[0] == 0}, y[x], {x, 0, 10}]


Greetings
POSTED BY: Luis Ledesma
The "if" needs to start with the uppercase "I" as in "If". All built-in Mathematica commands must start with uppcase letters.
POSTED BY: Isaac Abraham
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