Group Abstract Group Abstract

Message Boards Message Boards

0
|
7.8K Views
|
10 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Use apostrophe for derivative?

Posted 6 years ago

I wrote a code about 7 months ago. It worked in

https://develop.open.wolframcloud.com/objects/wpc-welcome/ThingsToTry.nb

but now it does not. I created an array named pHFit, and then its derivative pHD using pHD=pHFit'

then I plot both arrays in the same plot. Before, I got both curves but now only the first one. Please help and thanks in advance.

POSTED BY: YS Cheung
10 Replies
Posted 6 years ago

I just found that if I put all codes into a single line, it works (see below). But if I had a line break anywhere, the derivative curve is missing (also see below).

enter image description here

enter image description here

POSTED BY: YS Cheung
Posted 6 years ago

Thanks for trying it out in your PC.

Very strange! It doesn't work in my PC (see below).

I tried for Firefox and Chrome and it didn't work in both browsers (both updated). My PC is Windows 10 Enterprise 64-bit. I also tried it on another PC with Windows 7Enterprise 32-bit. it didn't work too. I also restarted the sessions.

By the way, I didn't sign in Wolfram when I tried it. Does it matter?

enter image description here

POSTED BY: YS Cheung
Posted 6 years ago

I cut and pasted the example provided and it works

$Version
(* 12.0.0 for Mac OS X x86 (64-bit) (April 7, 2019) *)

a = Table[{i, i^2 - 3 i + 2 + 0.3 Random[]}, {i, -1, 3, 0.1}]; 
ListPlot[a]; 
b = Interpolation[a, Method -> "Spline"];
c =  b'; 
Plot[Evaluate[{b[x], c[x]}], {x, -1, 3}]

enter image description here

POSTED BY: Rohit Namjoshi
Posted 6 years ago

My code is quite lengthy. Maybe I post another one (from other people) which I modified from to get mine.

a=Table[{i, i^2 - 3 i + 2 + 0.3 Random[]}, {i, -1, 3, 0.1}]; ListPlot[a]; b = Interpolation[a, Method -> "Spline"]; c = b'; Plot[Evaluate[{b[x], c[x]}], {x, -1, 3}]

Before, the plot consisted of two curves: a blue one for "b" and a red one for "c". Now when the code is run, there is only the blue curve for "b".

By the way, what do you mean by "notebook"? (Sorry that I am a beginner and not familiar with many terms.)

And if necessary, I can post my lengthy code. Thanks.

POSTED BY: YS Cheung

Please provide the entire code, and the notebook. Otherwise the community will be unable to help you. It can easily be a quote-like character; it is a common mistakeĀ…

POSTED BY: Sander Huisman
Posted 6 years ago

Can you check the incriminated apostrophes?

Sorry that I can't follow you (on how to do the checking).

By the way, I tried another thing: the following is from the Documentation Center, as an example of derivative:

f[x_] := Sin[x] + x^2;f'[x]

it works even though I paste it into word first and then copy&paste it back to the Wolfram platform, so it seems that Word doesn't plays "smart". Maybe the problem is applying derivative on an array?

And I also tried typing the apostrophe character directly (the one on the left of the enter key, right?), but it still doesn't work.

POSTED BY: YS Cheung

I would be very wary of copying and pasting from Word, which plays "smart" with quotes. You had better use an ascii text editor. Can you check the incriminated apostrophes?

POSTED BY: Gianluca Gorni
Posted 6 years ago

The apostrophes I used in the past and now should be the same because I copied and pasted the code used before into a Word file and now I just copy and paste it into https://develop.open.wolframcloud.com/objects/wpc-welcome/ThingsToTry.nb again. Thanks for your reply nevertheless.

POSTED BY: YS Cheung

Maybe you are using a character that looks similar to an apostrophe:

ToCharacterCode["'\[OpenCurlyQuote]\[CloseCurlyQuote]\[Prime]`"]
POSTED BY: Gianluca Gorni

Yes, Gianluca. I have made that mistake before.

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